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)
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to