[klibc] [klibc:update-dash] jobs: Handle string-based job descriptors
klibc-bot for Stephen Kitt
steve at sk2.org
Thu Jan 24 19:15:42 PST 2019
Commit-ID: f97573c5c1a47595c5a059b84b74f54cb2cd8d6d
Gitweb: http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=f97573c5c1a47595c5a059b84b74f54cb2cd8d6d
Author: Stephen Kitt <steve at sk2.org>
AuthorDate: Mon, 6 Jun 2016 22:45:27 +0800
Committer: Ben Hutchings <ben at decadent.org.uk>
CommitDate: Fri, 25 Jan 2019 02:57:21 +0000
[klibc] jobs: Handle string-based job descriptors
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 at sk2.org>
Signed-off-by: Herbert Xu <herbert at gondor.apana.org.au>
Signed-off-by: Ben Hutchings <ben at decadent.org.uk>
---
usr/dash/jobs.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/usr/dash/jobs.c b/usr/dash/jobs.c
index 7c324b76..5e080f6a 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";
More information about the klibc
mailing list