diff options
author | jilles <jilles@FreeBSD.org> | 2010-12-05 16:09:03 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2010-12-05 16:09:03 +0000 |
commit | 81a44f4bf1c74bad4c91a4770d559ca650697a01 (patch) | |
tree | 1e9f4e103f9294e6898bbfebc7a8b715a6ec86dd /bin/sh/jobs.c | |
parent | fb1c48789ea475d4f325412db997363968b23e92 (diff) | |
download | FreeBSD-src-81a44f4bf1c74bad4c91a4770d559ca650697a01.zip FreeBSD-src-81a44f4bf1c74bad4c91a4770d559ca650697a01.tar.gz |
sh: jobs -p: Do not ask the kernel for the pgid.
The getpgid() call will fail if the first process in the job has already
terminated, resulting in output of "-1".
The pgid of a job is always the pid of the first process in the job and
other code already relies on this.
Diffstat (limited to 'bin/sh/jobs.c')
-rw-r--r-- | bin/sh/jobs.c | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/bin/sh/jobs.c b/bin/sh/jobs.c index 8722f67..1b7a6d4 100644 --- a/bin/sh/jobs.c +++ b/bin/sh/jobs.c @@ -308,7 +308,6 @@ showjob(struct job *jp, pid_t pid, int mode) struct procstat *ps; struct job *j; int col, curr, i, jobno, prev, procno; - pid_t ppid; char c; procno = (mode == SHOWJOBS_PGIDS) ? 1 : jp->nprocs; @@ -323,9 +322,7 @@ showjob(struct job *jp, pid_t pid, int mode) #endif for (ps = jp->ps ; ; ps++) { /* for each process */ if (mode == SHOWJOBS_PIDS || mode == SHOWJOBS_PGIDS) { - ppid = (mode == SHOWJOBS_PIDS) ? ps->pid : - getpgid(ps->pid); - out1fmt("%d\n", (int)ppid); + out1fmt("%d\n", (int)ps->pid); goto skip; } if (mode != SHOWJOBS_VERBOSE && ps != jp->ps && pid == 0) |