diff options
| author | Laurent Bercot <ska-skaware@skarnet.org> | 2026-01-24 15:24:26 +0000 |
|---|---|---|
| committer | Laurent Bercot <ska-skaware@skarnet.org> | 2026-01-24 15:24:26 +0000 |
| commit | 1f3e97748180e36cdf6630d60019895e9a7f9a0c (patch) | |
| tree | 590fa9323605f091db78e5d6c536639e7f060502 | |
| parent | e0e5f7595a26fab026391eb682173d1ec72df335 (diff) | |
| download | s6-1f3e97748180e36cdf6630d60019895e9a7f9a0c.tar.gz | |
Add initial cleanup to s6-svscan
| -rw-r--r-- | src/supervision/s6-svscan.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/supervision/s6-svscan.c b/src/supervision/s6-svscan.c index 898c232..f943965 100644 --- a/src/supervision/s6-svscan.c +++ b/src/supervision/s6-svscan.c @@ -475,6 +475,23 @@ static int remove_deadinactive_iter (void *data, void *aux) return 1 ; } +static inline void initial_cleanup (void) +{ + DIR *dir = opendir(".") ; + if (!dir) strerr_diefu1sys(111, "opendir .") ; + for (;;) + { + direntry *d ; + errno = 0 ; + d = readdir(dir) ; + if (!d) break ; + if (d->d_name[0] == '.') continue ; + if (access(d->d_name, X_OK) == -1 && errno == ENOENT) unlink_void(d->d_name) ; + } + if (errno) strerr_diefu1sys(111, "readdir .") ; + dir_close(dir) ; +} + static void scan (unsigned int *what) { DIR *dir = opendir(".") ; @@ -688,8 +705,8 @@ int main (int argc, char const *const *argv) x[1].fd = control_init() ; x[0].fd = selfpipe_init() ; if (x[0].fd < 0) strerr_diefu1sys(111, "selfpipe_init") ; - if (!sig_altignore(SIGPIPE)) strerr_diefu1sys(111, "ignore SIGPIPE") ; + { sigset_t set ; sigemptyset(&set) ; @@ -710,6 +727,8 @@ int main (int argc, char const *const *argv) #endif if (!selfpipe_trapset(&set)) strerr_diefu1sys(111, "trap signals") ; } + + initial_cleanup() ; if (notif) { write(notif, "\n", 1) ; @@ -751,7 +770,7 @@ int main (int argc, char const *const *argv) tain deadline = scan_deadline ; tain_earliest1(&deadline, &start_deadline) ; r = iopause_g(x, 2, &deadline) ; - if (r < 0) panic("iopause") ; + if (r == -1) panic("iopause") ; else if (!r) { if (!tain_future(&scan_deadline)) scan(&what) ; |
