svn commit: r251429 - in head: bin/sh tools/regression/bin/sh/builtins

Jilles Tjoelker jilles at FreeBSD.org
Wed Jun 5 19:08:23 UTC 2013


Author: jilles
Date: Wed Jun  5 19:08:22 2013
New Revision: 251429
URL: http://svnweb.freebsd.org/changeset/base/251429

Log:
  sh: Allow multiple operands in wait builtin.
  
  This is only part of the PR; the behaviour for unknown/invalid pids/jobs
  remains unchanged (aborts the builtin with status 2).
  
  PR:		176916
  Submitted by:	Vadim Goncharov

Added:
  head/tools/regression/bin/sh/builtins/wait8.0   (contents, props changed)
Modified:
  head/bin/sh/jobs.c

Modified: head/bin/sh/jobs.c
==============================================================================
--- head/bin/sh/jobs.c	Wed Jun  5 18:49:28 2013	(r251428)
+++ head/bin/sh/jobs.c	Wed Jun  5 19:08:22 2013	(r251429)
@@ -95,6 +95,7 @@ static int ttyfd = -1;
 static void restartjob(struct job *);
 #endif
 static void freejob(struct job *);
+static int waitcmdloop(struct job *);
 static struct job *getjob(char *);
 pid_t getjobpgrp(char *);
 static pid_t dowait(int, struct job *);
@@ -459,15 +460,26 @@ int
 waitcmd(int argc __unused, char **argv __unused)
 {
 	struct job *job;
-	int status, retval;
-	struct job *jp;
+	int retval;
 
 	nextopt("");
-	if (*argptr != NULL) {
+	if (*argptr == NULL)
+		return (waitcmdloop(NULL));
+
+	do {
 		job = getjob(*argptr);
-	} else {
-		job = NULL;
-	}
+		retval = waitcmdloop(job);
+		argptr++;
+	} while (*argptr != NULL);
+
+	return (retval);
+}
+
+static int
+waitcmdloop(struct job *job)
+{
+	int status, retval;
+	struct job *jp;
 
 	/*
 	 * Loop until a process is terminated or stopped, or a SIGINT is

Added: head/tools/regression/bin/sh/builtins/wait8.0
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/tools/regression/bin/sh/builtins/wait8.0	Wed Jun  5 19:08:22 2013	(r251429)
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+exit 44 & p44=$!
+exit 45 & p45=$!
+exit 7 & p7=$!
+wait "$p44" "$p7" "$p45"
+[ "$?" = 45 ]


More information about the svn-src-all mailing list