diff options
| author | Laurent Bercot <ska-skaware@skarnet.org> | 2025-10-22 03:03:53 +0000 |
|---|---|---|
| committer | Laurent Bercot <ska-skaware@skarnet.org> | 2025-10-22 03:03:53 +0000 |
| commit | b1b5cca013c200014799953dd40d0b9e2ea88e63 (patch) | |
| tree | 80e4b395c7d401fb20a5315a18c9c028017b5542 /src/supervision/s6-background-watch.c | |
| parent | a384be48fd6039ed4ecd48ba98008ecf5c8505a7 (diff) | |
| download | s6-b1b5cca013c200014799953dd40d0b9e2ea88e63.tar.gz | |
Add some doc, improve s6-background-watch
Diffstat (limited to 'src/supervision/s6-background-watch.c')
| -rw-r--r-- | src/supervision/s6-background-watch.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/supervision/s6-background-watch.c b/src/supervision/s6-background-watch.c index cfb1fb7..847e844 100644 --- a/src/supervision/s6-background-watch.c +++ b/src/supervision/s6-background-watch.c @@ -124,7 +124,8 @@ static inline int handle_signals (pid_t pid, int issr, int *code) } -/* BSD part. kevent is a unique snowflake in the shape of a dildo */ +/* BSD part. kevent is a unique dildo-shaped snowflake, so we need to run it + in its own thread for it to play nicely with our regular iopause loop. */ #ifdef SKALIBS_HASKEVENT @@ -162,7 +163,6 @@ static void keventstart (pid_t pid, int *fd, pthread_t *th) EV_SET(&ke, pid, EVFILT_PROC, EV_ADD | EV_ONESHOT, NOTE_EXIT, 0, 0) ; if (kevent(t.kq, &ke, 1, 0, 0, 0) == -1) strerr_diefu1sys(111, "register kevent") ; if (pipe(p) == -1) strerr_diefu2sys(111, "pipe") ; - if (coe(p[0]) t.fdw = p[1] ; t.pid = pid ; e = pthread_attr_init(&attr) ; @@ -201,7 +201,7 @@ static gol_arg const rgola[GOLA_N] = int main (int argc, char const *const *argv) { - iopause_fd x[2] = { { .events = IOPAUSE_READ }, { .events = IOPAUSE_READ, .revents = 0 } } ; + iopause_fd x[2] = { { .events = IOPAUSE_READ }, { .fd = -2, .events = IOPAUSE_READ, .revents = 0 } } ; tain tto = TAIN_INFINITE_RELATIVE ; tain deadline ; unsigned int notif = 0 ; @@ -238,7 +238,6 @@ int main (int argc, char const *const *argv) #ifdef SKALIBS_HASPRSETCHILDSUBREAPER if (prctl(PR_SET_CHILD_SUBREAPER, 1) == -1) strerr_diefu1sys(111, "prctl to become a subreaper") ; - x[1].fd = -2 ; #endif pid = cspawn(argv[1], argv + 1, (char const *const *)environ, CSPAWN_FLAGS_SELFPIPE_FINISH, 0, 0) ; @@ -259,8 +258,10 @@ int main (int argc, char const *const *argv) } pid = get_pid_from_pidfile(argv[0], argv[1]) ; + if (kill(pid, 0) == -1) strerr_diefu1sys(111, "check daemon with a null signal") ; + #ifdef SKALIBS_HASKEVENT - pthread_t th ; + pthread_t th = PTHREAD_NULL ; keventstart(pid, &x[1].fd, &th) ; #endif if (notif) |
