reaper: add optional callback

When calling ‘reaper_add()’, the caller can provide a callback. If
non-NULL, the reaper will call the callback to handle the actual
reaping.

If the callback is NULL, or if it returns false, the reaper reaps the
child process.
This commit is contained in:
Daniel Eklöf 2020-12-26 01:26:54 +01:00
parent d778dc3d2a
commit 3c6789fb8b
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
3 changed files with 40 additions and 21 deletions

View file

@ -55,7 +55,7 @@ spawn(struct reaper *reaper, const char *cwd, char *const argv[],
close(pipe_fds[0]);
if (ret == 0) {
reaper_add(reaper, pid);
reaper_add(reaper, pid, NULL, NULL);
return true;
} else if (ret < 0) {
LOG_ERRNO("failed to read from pipe");