Sort headers

Constify long options
Remove useless call to sigemptyset
properly check errno when waiting for a process status when a SIGCHLD is received
This commit is contained in:
Baptiste Daroussin 2014-07-16 11:41:28 +00:00
parent a2072d9e0f
commit 86b0545ed1

View File

@ -28,20 +28,18 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
__FBSDID("$FreeBSD$"); __FBSDID("$FreeBSD$");
#include <sys/types.h> #include <err.h>
#include <sys/time.h> #include <errno.h>
#include <sys/wait.h> #include <getopt.h>
#include <signal.h> #include <signal.h>
#include <stdbool.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <sysexits.h> #include <sysexits.h>
#include <unistd.h> #include <unistd.h>
#include <getopt.h>
#include <err.h>
#include <spawn.h>
#include <errno.h>
#include <stdbool.h>
#define EXIT_TIMEOUT 124 #define EXIT_TIMEOUT 124
@ -188,7 +186,7 @@ main(int argc, char **argv)
cpid = -1; cpid = -1;
pgid = -1; pgid = -1;
struct option longopts[] = { const struct option longopts[] = {
{ "preserve-status", no_argument, &preserve, 1 }, { "preserve-status", no_argument, &preserve, 1 },
{ "foreground", no_argument, &foreground, 1 }, { "foreground", no_argument, &foreground, 1 },
{ "kill-after", required_argument, NULL, 'k'}, { "kill-after", required_argument, NULL, 'k'},
@ -271,15 +269,13 @@ main(int argc, char **argv)
/* parent continues here */ /* parent continues here */
set_interval(first_kill); set_interval(first_kill);
sigemptyset(&signals.sa_mask);
for (;;) { for (;;) {
sigemptyset(&signals.sa_mask); sigemptyset(&signals.sa_mask);
sigsuspend(&signals.sa_mask); sigsuspend(&signals.sa_mask);
if (sig_chld) { if (sig_chld) {
sig_chld = 0; sig_chld = 0;
while (((cpid = wait(&status)) < 0) && errno != EINTR) while (((cpid = wait(&status)) < 0) && errno == EINTR)
continue; continue;
if (cpid == pid) { if (cpid == pid) {