svn commit: r327212 - head/bin/sh

Jilles Tjoelker jilles at FreeBSD.org
Tue Dec 26 16:23:20 UTC 2017


Author: jilles
Date: Tue Dec 26 16:23:18 2017
New Revision: 327212
URL: https://svnweb.freebsd.org/changeset/base/327212

Log:
  sh: Don't leak wait* implementation details from jobs.c

Modified:
  head/bin/sh/eval.c
  head/bin/sh/jobs.c

Modified: head/bin/sh/eval.c
==============================================================================
--- head/bin/sh/eval.c	Tue Dec 26 16:20:38 2017	(r327211)
+++ head/bin/sh/eval.c	Tue Dec 26 16:23:18 2017	(r327212)
@@ -43,7 +43,6 @@ __FBSDID("$FreeBSD$");
 #include <stdlib.h>
 #include <unistd.h>
 #include <sys/resource.h>
-#include <sys/wait.h> /* For WIFSIGNALED(status) */
 #include <errno.h>
 
 /*
@@ -840,7 +839,7 @@ evalcommand(union node *cmd, int flags, struct backcmd
 	struct parsefile *savetopfile;
 	volatile int e;
 	char *lastarg;
-	int realstatus;
+	int signaled;
 	int do_clearcmdentry;
 	const char *path = pathval();
 	int i;
@@ -1163,9 +1162,9 @@ cmddone:
 parent:	/* parent process gets here (if we forked) */
 	if (mode == FORK_FG) {	/* argument to fork */
 		INTOFF;
-		exitstatus = waitforjob(jp, &realstatus);
+		exitstatus = waitforjob(jp, &signaled);
 		INTON;
-		if (iflag && loopnest > 0 && WIFSIGNALED(realstatus)) {
+		if (iflag && loopnest > 0 && signaled) {
 			evalskip = SKIPBREAK;
 			skipcount = loopnest;
 		}

Modified: head/bin/sh/jobs.c
==============================================================================
--- head/bin/sh/jobs.c	Tue Dec 26 16:20:38 2017	(r327211)
+++ head/bin/sh/jobs.c	Tue Dec 26 16:23:18 2017	(r327212)
@@ -1016,7 +1016,7 @@ vforkexecshell(struct job *jp, char **argv, char **env
  */
 
 int
-waitforjob(struct job *jp, int *origstatus)
+waitforjob(struct job *jp, int *signaled)
 {
 #if JOBS
 	int propagate_int = jp->jobctl && jp->foreground;
@@ -1039,8 +1039,8 @@ waitforjob(struct job *jp, int *origstatus)
 		setcurjob(jp);
 #endif
 	status = jp->ps[jp->nprocs - 1].status;
-	if (origstatus != NULL)
-		*origstatus = status;
+	if (signaled != NULL)
+		*signaled = WIFSIGNALED(status);
 	/* convert to 8 bits */
 	if (WIFEXITED(status))
 		st = WEXITSTATUS(status);


More information about the svn-src-head mailing list