diff options
author | bapt <bapt@FreeBSD.org> | 2014-07-16 11:41:28 +0000 |
---|---|---|
committer | bapt <bapt@FreeBSD.org> | 2014-07-16 11:41:28 +0000 |
commit | 454c984331837c8f37ab33ab8a8129ae1b47587f (patch) | |
tree | c6e64a85aa5679f9f3703e874930af976ca995a7 /usr.bin/timeout | |
parent | 8ccdbe84e0398b5f6cd7e031328d8bc98e2a6993 (diff) | |
download | FreeBSD-src-454c984331837c8f37ab33ab8a8129ae1b47587f.zip FreeBSD-src-454c984331837c8f37ab33ab8a8129ae1b47587f.tar.gz |
Sort headers
Constify long options
Remove useless call to sigemptyset
properly check errno when waiting for a process status when a SIGCHLD is received
Diffstat (limited to 'usr.bin/timeout')
-rw-r--r-- | usr.bin/timeout/timeout.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/usr.bin/timeout/timeout.c b/usr.bin/timeout/timeout.c index 2842800..7248fe5 100644 --- a/usr.bin/timeout/timeout.c +++ b/usr.bin/timeout/timeout.c @@ -28,20 +28,18 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include <sys/types.h> -#include <sys/time.h> -#include <sys/wait.h> +#include <err.h> +#include <errno.h> +#include <getopt.h> #include <signal.h> +#include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <sys/time.h> +#include <sys/wait.h> #include <sysexits.h> #include <unistd.h> -#include <getopt.h> -#include <err.h> -#include <spawn.h> -#include <errno.h> -#include <stdbool.h> #define EXIT_TIMEOUT 124 @@ -188,7 +186,7 @@ main(int argc, char **argv) cpid = -1; pgid = -1; - struct option longopts[] = { + const struct option longopts[] = { { "preserve-status", no_argument, &preserve, 1 }, { "foreground", no_argument, &foreground, 1 }, { "kill-after", required_argument, NULL, 'k'}, @@ -271,15 +269,13 @@ main(int argc, char **argv) /* parent continues here */ set_interval(first_kill); - sigemptyset(&signals.sa_mask); - for (;;) { sigemptyset(&signals.sa_mask); sigsuspend(&signals.sa_mask); if (sig_chld) { sig_chld = 0; - while (((cpid = wait(&status)) < 0) && errno != EINTR) + while (((cpid = wait(&status)) < 0) && errno == EINTR) continue; if (cpid == pid) { |