summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2013-06-05 19:40:52 +0000
committerjilles <jilles@FreeBSD.org>2013-06-05 19:40:52 +0000
commit34ac6a12ea10118be8a1ce462ed7964d50d7ac63 (patch)
treec2bae67da1d59d1debe2e47243f65cff71574f84 /bin
parentdbbdb077d82c797a0eda74194fcf16f3264030ab (diff)
downloadFreeBSD-src-34ac6a12ea10118be8a1ce462ed7964d50d7ac63.zip
FreeBSD-src-34ac6a12ea10118be8a1ce462ed7964d50d7ac63.tar.gz
sh: Return status 127 for unknown jobs in wait builtin.
This is required by POSIX, at least for pids that are not known child processes. Other problems with job specifications still cause wait to abort with exit status 2. PR: 176916
Diffstat (limited to 'bin')
-rw-r--r--bin/sh/jobs.c24
1 files changed, 19 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)
{
OpenPOWER on IntegriCloud