commit 973289bd9e7d15650425d2cf02a87b71fc7ce405
parent b59ba335e9c7834c17190de4bad650a364fbb7da
Author: Friedel Schon <[email protected]>
Date: Sat, 29 Apr 2023 22:38:24 +0200
fixing musl-warnings
Diffstat:
5 files changed, 33 insertions(+), 28 deletions(-)
diff --git a/src/exec/fsvc.c b/src/exec/fsvc.c
@@ -21,6 +21,9 @@ static const char VERSION_MESSAGE[] =
void print_status(service_t* s, char* state, size_t size) {
switch (s->state) {
+ case STATE_SETUP:
+ strcpy(state, "setup");
+ break;
case STATE_INACTIVE:
strcpy(state, "inactive");
break;
diff --git a/src/exec/seedrng.c b/src/exec/seedrng.c
@@ -11,7 +11,7 @@
#include <string.h>
#include <sys/file.h>
#include <sys/ioctl.h>
-#include <sys/poll.h>
+#include <poll.h>
#include <sys/random.h>
#include <sys/stat.h>
#include <time.h>
diff --git a/src/service.c b/src/service.c
@@ -4,21 +4,22 @@
#include <dirent.h>
#include <errno.h>
+#include <limits.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/wait.h>
-service_t services[SV_SERVICE_MAX];
-int services_size = 0;
-char runlevel[SV_NAME_MAX];
-const char* service_dir;
-int control_socket;
-int null_fd;
-bool verbose = false;
+service_t services[SV_SERVICE_MAX];
+int services_size = 0;
+char runlevel[SV_NAME_MAX];
+const char* service_dir;
+int control_socket;
+int null_fd;
+bool verbose = false;
dependency_t depends[SV_DEPENDENCY_MAX];
-int depends_size;
+int depends_size;
service_t* service_get(const char* name) {
@@ -39,7 +40,7 @@ int service_pattern(const char* name, service_t** dest, int dest_max) {
}
int service_refresh() {
- DIR* dp;
+ DIR* dp;
struct dirent* ep;
dp = opendir(service_dir);
if (dp == NULL) {
@@ -48,7 +49,7 @@ int service_refresh() {
}
struct stat stat_str;
- char path_buffer[PATH_MAX];
+ char path_buffer[PATH_MAX];
for (int i = 0; i < services_size; i++) {
service_t* s = &services[i];
@@ -98,8 +99,8 @@ bool service_need_restart(service_t* s) {
if (s->restart_manual == S_FORCE_DOWN)
return is_dependency(s);
return s->restart_file == S_ONCE ||
- s->restart_file == S_RESTART ||
- s->restart_manual == S_ONCE ||
- s->restart_manual == S_RESTART ||
- is_dependency(s);
+ s->restart_file == S_RESTART ||
+ s->restart_manual == S_ONCE ||
+ s->restart_manual == S_RESTART ||
+ is_dependency(s);
}
\ No newline at end of file
diff --git a/src/stage.c b/src/stage.c
@@ -22,7 +22,7 @@ void sigblock_all(bool unblock) {
}
void handle_stage1() {
- int pid, ttyfd, exitstat;
+ int pid, ttyfd, exitstat;
sigset_t ss;
while ((pid = fork()) == -1) {
print_error("unable to fork for stage1");
@@ -35,7 +35,7 @@ void handle_stage1() {
if ((ttyfd = open("/dev/console", O_RDWR)) == -1) {
print_error("unable to open /dev/console");
} else {
- ioctl(ttyfd, TIOCSCTTY, NULL); // make the controlling process
+ ioctl(ttyfd, TIOCSCTTY, NULL); // make the controlling process
dup2(ttyfd, 0);
if (ttyfd > 2) close(ttyfd);
}
@@ -44,8 +44,8 @@ void handle_stage1() {
struct sigaction sigact = { 0 };
- sigact.sa_handler = SIG_DFL;
- sigaction(SIGCLD, &sigact, NULL);
+ sigact.sa_handler = SIG_DFL;
+ sigaction(SIGCHLD, &sigact, NULL);
sigaction(SIGINT, &sigact, NULL);
sigact.sa_handler = SIG_IGN;
@@ -120,7 +120,7 @@ void handle_stage1() {
void handle_stage3() {
- int pid, ttyfd, exitstat;
+ int pid, ttyfd, exitstat;
sigset_t ss;
while ((pid = fork()) == -1) {
print_error("unable to fork for state3");
@@ -135,8 +135,8 @@ void handle_stage3() {
struct sigaction sigact = { 0 };
- sigact.sa_handler = SIG_DFL;
- sigaction(SIGCLD, &sigact, NULL);
+ sigact.sa_handler = SIG_DFL;
+ sigaction(SIGCHLD, &sigact, NULL);
sigaction(SIGINT, &sigact, NULL);
sigact.sa_handler = SIG_IGN;
diff --git a/src/supervise.c b/src/supervise.c
@@ -5,6 +5,7 @@
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/un.h>
@@ -17,8 +18,8 @@ bool daemon_running = true;
static void signal_child(int unused) {
(void) unused;
- int status;
- pid_t died_pid;
+ int status;
+ pid_t died_pid;
service_t* s = NULL;
if ((died_pid = wait(&status)) == -1) {
@@ -85,7 +86,7 @@ static void accept_socket() {
int service_supervise(const char* service_dir_, const char* runlevel_, bool force_socket) {
struct sigaction sigact = { 0 };
- sigact.sa_handler = signal_child;
+ sigact.sa_handler = signal_child;
sigaction(SIGCHLD, &sigact, NULL);
sigact.sa_handler = SIG_IGN;
sigaction(SIGPIPE, &sigact, NULL);
@@ -127,7 +128,7 @@ int service_supervise(const char* service_dir_, const char* runlevel_, bool forc
// bind socket to address
struct sockaddr_un addr = { 0 };
- addr.sun_family = AF_UNIX;
+ addr.sun_family = AF_UNIX;
strcpy(addr.sun_path, socket_path);
if (bind(control_socket, (struct sockaddr*) &addr, sizeof(addr)) == -1) {
print_error("cannot bind %s to socket", socket_path);
@@ -171,9 +172,9 @@ int service_supervise(const char* service_dir_, const char* runlevel_, bool forc
}
time_t start = time(NULL);
- int running;
+ int running;
do {
- sleep(1); // sleep for one second
+ sleep(1); // sleep for one second
running = 0;
for (int i = 0; i < services_size; i++) {
if (services[i].state != STATE_INACTIVE)