Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 5 Dec 2010 16:09:03 +0000 (UTC)
From:      Jilles Tjoelker <jilles@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r216199 - head/bin/sh
Message-ID:  <201012051609.oB5G93Sq099419@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jilles
Date: Sun Dec  5 16:09:03 2010
New Revision: 216199
URL: http://svn.freebsd.org/changeset/base/216199

Log:
  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.

Modified:
  head/bin/sh/jobs.c

Modified: head/bin/sh/jobs.c
==============================================================================
--- head/bin/sh/jobs.c	Sun Dec  5 10:15:23 2010	(r216198)
+++ head/bin/sh/jobs.c	Sun Dec  5 16:09:03 2010	(r216199)
@@ -308,7 +308,6 @@ showjob(struct job *jp, pid_t pid, int m
 	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 m
 #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)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201012051609.oB5G93Sq099419>