version 1.6, 2021/09/01 16:12:38 |
version 1.7, 2021/09/01 19:54:34 |
|
|
return; |
return; |
} |
} |
|
|
switch(signo) { |
switch (signo) { |
case SIGINT: |
case SIGINT: |
case SIGHUP: |
case SIGHUP: |
case SIGQUIT: |
case SIGQUIT: |
|
|
argv++; |
argv++; |
|
|
if (!foreground) { |
if (!foreground) { |
pgid = setpgid(0,0); |
pgid = setpgid(0, 0); |
|
|
if (pgid == -1) |
if (pgid == -1) |
err(1, "setpgid()"); |
err(1, "setpgid()"); |
|
|
if (killsig != SIGKILL && killsig != SIGSTOP) |
if (killsig != SIGKILL && killsig != SIGSTOP) |
signums[0] = killsig; |
signums[0] = killsig; |
|
|
for (i = 0; i < sizeof(signums) / sizeof(signums[0]); i ++) |
for (i = 0; i < sizeof(signums) / sizeof(signums[0]); i++) |
sigaddset(&signals.sa_mask, signums[i]); |
sigaddset(&signals.sa_mask, signums[i]); |
|
|
signals.sa_handler = sig_handler; |
signals.sa_handler = sig_handler; |
signals.sa_flags = SA_RESTART; |
signals.sa_flags = SA_RESTART; |
|
|
for (i = 0; i < sizeof(signums) / sizeof(signums[0]); i ++) { |
for (i = 0; i < sizeof(signums) / sizeof(signums[0]); i++) { |
if (signums[i] != -1 && signums[i] != 0 && |
if (signums[i] != -1 && signums[i] != 0 && |
sigaction(signums[i], &signals, NULL) == -1) |
sigaction(signums[i], &signals, NULL) == -1) |
err(1, "sigaction()"); |
err(1, "sigaction()"); |
|
|
} |
} |
} |
} |
|
|
while (cpid != pid && wait(&pstat) == -1) { |
while (cpid != pid && wait(&pstat) == -1) { |
if (errno != EINTR) |
if (errno != EINTR) |
err(1, "waitpid()"); |
err(1, "waitpid()"); |
} |
} |
|
|
if (WEXITSTATUS(pstat)) |
if (WEXITSTATUS(pstat)) |
pstat = WEXITSTATUS(pstat); |
pstat = WEXITSTATUS(pstat); |
else if(WIFSIGNALED(pstat)) |
else if (WIFSIGNALED(pstat)) |
pstat = 128 + WTERMSIG(pstat); |
pstat = 128 + WTERMSIG(pstat); |
|
|
if (timedout && !preserve) |
if (timedout && !preserve) |