diff options
-rw-r--r-- | bin/sh/jobs.c | 24 | ||||
-rw-r--r-- | tools/regression/bin/sh/builtins/wait10.0 | 5 | ||||
-rw-r--r-- | tools/regression/bin/sh/builtins/wait9.127 | 3 |
3 files changed, 27 insertions, 5 deletions
diff --git a/bin/sh/jobs.c b/bin/sh/jobs.c index aa8d988..7129a9f 100644 --- a/bin/sh/jobs.c +++ b/bin/sh/jobs.c @@ -96,6 +96,7 @@ static void restartjob(struct job *); #endif static void freejob(struct job *); static int waitcmdloop(struct job *); +static struct job *getjob_nonotfound(char *); static struct job *getjob(char *); pid_t getjobpgrp(char *); static pid_t dowait(int, struct job *); @@ -467,8 +468,11 @@ waitcmd(int argc __unused, char **argv __unused) return (waitcmdloop(NULL)); do { - job = getjob(*argptr); - retval = waitcmdloop(job); + job = getjob_nonotfound(*argptr); + if (job == NULL) + retval = 127; + else + retval = waitcmdloop(job); argptr++; } while (*argptr != NULL); @@ -558,7 +562,7 @@ jobidcmd(int argc __unused, char **argv) */ static struct job * -getjob(char *name) +getjob_nonotfound(char *name) { int jobno; struct job *found, *jp; @@ -623,12 +627,22 @@ currentjob: if ((jp = getcurjob(NULL)) == NULL) return jp; } } - error("No such job: %s", name); - /*NOTREACHED*/ return NULL; } +static struct job * +getjob(char *name) +{ + struct job *jp; + + jp = getjob_nonotfound(name); + if (jp == NULL) + error("No such job: %s", name); + return (jp); +} + + pid_t getjobpgrp(char *name) { diff --git a/tools/regression/bin/sh/builtins/wait10.0 b/tools/regression/bin/sh/builtins/wait10.0 new file mode 100644 index 0000000..864fc78 --- /dev/null +++ b/tools/regression/bin/sh/builtins/wait10.0 @@ -0,0 +1,5 @@ +# $FreeBSD$ +# Init cannot be a child of the shell. +exit 49 & p49=$! +wait 1 "$p49" +[ "$?" = 49 ] diff --git a/tools/regression/bin/sh/builtins/wait9.127 b/tools/regression/bin/sh/builtins/wait9.127 new file mode 100644 index 0000000..661f275 --- /dev/null +++ b/tools/regression/bin/sh/builtins/wait9.127 @@ -0,0 +1,3 @@ +# $FreeBSD$ +# Init cannot be a child of the shell. +wait 1 |