Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 16 Jul 2014 11:41:28 +0000 (UTC)
From:      Baptiste Daroussin <bapt@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r268750 - head/usr.bin/timeout
Message-ID:  <201407161141.s6GBfSbS034790@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bapt
Date: Wed Jul 16 11:41:28 2014
New Revision: 268750
URL: http://svnweb.freebsd.org/changeset/base/268750

Log:
  Sort headers
  Constify long options
  Remove useless call to sigemptyset
  properly check errno when waiting for a process status when a SIGCHLD is received

Modified:
  head/usr.bin/timeout/timeout.c

Modified: head/usr.bin/timeout/timeout.c
==============================================================================
--- head/usr.bin/timeout/timeout.c	Wed Jul 16 11:30:04 2014	(r268749)
+++ head/usr.bin/timeout/timeout.c	Wed Jul 16 11:41:28 2014	(r268750)
@@ -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) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201407161141.s6GBfSbS034790>