diff options
author | Leah Neukirchen <leah@vuxu.org> | 2022-02-16 00:22:59 +0100 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2022-02-16 13:49:01 +0100 |
commit | d15ba797f08bef5c234135e1a3360318c63c2205 (patch) | |
tree | 19b46e14d0d1a55c64b70b5b918306ff25b35305 | |
parent | 06769a66a616d4d984eb91614bb3e88d289de79c (diff) | |
download | rvnit-d15ba797f08bef5c234135e1a3360318c63c2205.tar.gz rvnit-d15ba797f08bef5c234135e1a3360318c63c2205.tar.xz rvnit-d15ba797f08bef5c234135e1a3360318c63c2205.zip |
formatting
-rw-r--r-- | rvnit.c | 58 |
1 files changed, 36 insertions, 22 deletions
diff --git a/rvnit.c b/rvnit.c index 2a054bd..46a1009 100644 --- a/rvnit.c +++ b/rvnit.c @@ -28,7 +28,7 @@ #define MAX_SV 512 // ## not truly portable :/ -#define LOG(fmt, ...) dprintf(selflogfd[1], fmt "\n", ## __VA_ARGS__); +#define LOG(fmt, ...) dprintf(selflogfd[1], fmt "\n",##__VA_ARGS__); enum { UNDEF, @@ -237,7 +237,7 @@ cleanup(int i) int charsig(char c) { - switch(c) { + switch (c) { case 'p': return SIGSTOP; case 'c': return SIGCONT; case 'h': return SIGHUP; @@ -254,7 +254,7 @@ charsig(char c) } void * -socket_loop(void* ignored) +socket_loop(void *ignored) { (void)ignored; @@ -290,10 +290,10 @@ socket_loop(void* ignored) } r = listen(listenfd, SOMAXCONN); - if (r < 0) { - perror("rvnit: listen"); - exit(111); - } + if (r < 0) { + perror("rvnit: listen"); + exit(111); + } while (1) { int connfd = accept4(listenfd, 0, 0, SOCK_CLOEXEC); @@ -398,7 +398,7 @@ socket_loop(void* ignored) } void * -logger_loop(void* ignored) +logger_loop(void *ignored) { (void)ignored; @@ -499,7 +499,7 @@ closed_pipe: // sometimes processes use multiple write calls // for one line, give them 25msec to do try to // get the whole line. - nanosleep(&(struct timespec){0, 25000000}, 0); + nanosleep(&(struct timespec) { 0, 25000000 }, 0); ssize_t rd2 = read(fds[j].fd, buf + rd, sizeof buf - rd); if (rd2 > 0) rd += rd2; @@ -655,7 +655,7 @@ rescandir() services[i].logged = 0; i++; -next: ; +next: ; } for (int j = 0; j < MAX_SV; j++) @@ -796,14 +796,20 @@ main(int argc, char *argv[]) ioctl(0, TIOCNOTTY); sigaction(SIGCHLD, &(struct sigaction){ - .sa_handler=on_signal, .sa_mask=allset, - .sa_flags=SA_NOCLDSTOP|SA_RESTART }, 0); + .sa_handler = on_signal, + .sa_mask = allset, + .sa_flags = SA_NOCLDSTOP|SA_RESTART + }, 0); sigaction(SIGINT, &(struct sigaction){ - .sa_handler=on_signal, .sa_mask=allset }, 0); + .sa_handler = on_signal, + .sa_mask = allset + }, 0); if (!real_pid1) { /* keep SIGTERM blocked on Linux for pid 1 by default. */ sigaction(SIGTERM, &(struct sigaction){ - .sa_handler=on_signal, .sa_mask=allset }, 0); + .sa_handler = on_signal, + .sa_mask = allset + }, 0); } int i; @@ -900,8 +906,10 @@ cont1: } } - sigaction(SIGCONT, - &(struct sigaction){ .sa_handler=on_signal, .sa_mask=allset }, 0); + sigaction(SIGCONT, &(struct sigaction){ + .sa_handler = on_signal, + .sa_mask = allset + }, 0); LOG("system up"); @@ -1002,14 +1010,20 @@ fatal: own_console(); sigaction(SIGINT, &(struct sigaction){ - .sa_handler=on_signal, .sa_mask=allset, - .sa_flags=SA_RESTART }, 0); + .sa_handler = on_signal, + .sa_mask = allset, + .sa_flags = SA_RESTART + }, 0); sigaction(SIGTERM, &(struct sigaction){ - .sa_handler=on_signal, .sa_mask=allset, - .sa_flags=SA_RESTART }, 0); + .sa_handler = on_signal, + .sa_mask = allset, + .sa_flags = SA_RESTART + }, 0); sigaction(SIGCONT, &(struct sigaction){ - .sa_handler=on_signal, .sa_mask=allset, - .sa_flags=SA_RESTART }, 0); + .sa_handler = on_signal, + .sa_mask = allset, + .sa_flags = SA_RESTART + }, 0); #ifdef __linux__ reboot(RB_ENABLE_CAD); |