diff options
author | Stephen Kitt <steve@sk2.org> | 2016-06-06 22:45:27 +0800 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2020-03-28 21:42:54 +0000 |
commit | 8115b5d06f75ea543d01355384cf5556aa388481 (patch) | |
tree | 5691907b49977bede695986efbae44374c796b45 | |
parent | b9c84707e06be25579b9402f740c763ed79cbdde (diff) | |
download | klibc-8115b5d06f75ea543d01355384cf5556aa388481.tar.gz |
[klibc] dash: jobs: Handle string-based job descriptors
[ dash commit 203e8395faa9135956e3b2a2b749b6dd96a7e988 ]
When looking for a job using a string descriptor, e.g.
fg %man
the relevant loop in src/jobs.c only ever exits to the err label. With
this patch, when the end condition is reached, we check whether a job
was found, and if so, set things up to exit correctly via gotit.
Multiple matches are already caught using the test in the match block.
Signed-off-by: Stephen Kitt <steve@sk2.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r-- | usr/dash/jobs.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/usr/dash/jobs.c b/usr/dash/jobs.c index 49c14441f51e6..c1f9688fc33b4 100644 --- a/usr/dash/jobs.c +++ b/usr/dash/jobs.c @@ -713,9 +713,7 @@ check: } found = 0; - while (1) { - if (!jp) - goto err; + while (jp) { if (match(jp->ps[0].cmd, p)) { if (found) goto err; @@ -725,6 +723,10 @@ check: jp = jp->prev_job; } + if (!found) + goto err; + jp = found; + gotit: #if JOBS err_msg = "job %s not created under job control"; |