Refactoring sigchld ref. #156 (#159)

This commit is contained in:
Stein Gunnar Bakkeby 2024-11-25 20:48:52 +01:00 committed by GitHub
parent c4c5113fbd
commit 4dec55eead
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 21 additions and 49 deletions

View file

@ -1,15 +1,18 @@
#include <sys/wait.h>
void
plumb(char *sel) {
plumb(char *sel)
{
if (sel == NULL)
return;
char cwd[PATH_MAX];
pid_t child;
if (subprocwd(cwd) != 0)
return;
switch(child = fork()) {
switch (child = fork()) {
case -1:
return;
case 0:
@ -18,7 +21,5 @@ plumb(char *sel) {
if (execvp(plumb_cmd, (char *const []){plumb_cmd, sel, 0}) == -1)
exit(1);
exit(0);
default:
waitpid(child, NULL, 0);
}
}
}