Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 18 Oct 2013 12:35:12 +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: r256735 - head/bin/sh
Message-ID:  <201310181235.r9ICZCLl039511@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jilles
Date: Fri Oct 18 12:35:12 2013
New Revision: 256735
URL: http://svnweb.freebsd.org/changeset/base/256735

Log:
  sh: Remove one syscall when waiting for a foreground job.
  
  The getpgrp() call is unnecessary: if there is no job control then the
  result was not used at all and if there is job control then we are not a
  subshell and our process group ID is equal to our process ID (rootpid).

Modified:
  head/bin/sh/jobs.c

Modified: head/bin/sh/jobs.c
==============================================================================
--- head/bin/sh/jobs.c	Fri Oct 18 12:31:32 2013	(r256734)
+++ head/bin/sh/jobs.c	Fri Oct 18 12:35:12 2013	(r256735)
@@ -978,7 +978,6 @@ int
 waitforjob(struct job *jp, int *origstatus)
 {
 #if JOBS
-	pid_t mypgrp = getpgrp();
 	int propagate_int = jp->jobctl && jp->foreground;
 #endif
 	int status;
@@ -992,7 +991,7 @@ waitforjob(struct job *jp, int *origstat
 			dotrap();
 #if JOBS
 	if (jp->jobctl) {
-		if (tcsetpgrp(ttyfd, mypgrp) < 0)
+		if (tcsetpgrp(ttyfd, rootpid) < 0)
 			error("tcsetpgrp failed, errno=%d\n", errno);
 	}
 	if (jp->state == JOBSTOPPED)



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