From owner-svn-src-all@FreeBSD.ORG Sun Dec 12 22:59:35 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 47AF11065670; Sun, 12 Dec 2010 22:59:35 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3679B8FC13; Sun, 12 Dec 2010 22:59:35 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oBCMxZCM062106; Sun, 12 Dec 2010 22:59:35 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oBCMxZA8062104; Sun, 12 Dec 2010 22:59:35 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201012122259.oBCMxZA8062104@svn.freebsd.org> From: Jilles Tjoelker Date: Sun, 12 Dec 2010 22:59:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r216400 - head/bin/sh X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Dec 2010 22:59:35 -0000 Author: jilles Date: Sun Dec 12 22:59:34 2010 New Revision: 216400 URL: http://svn.freebsd.org/changeset/base/216400 Log: sh: Various simplifications to jobs.c: * Prefer kill(-X) to killpg(X). * Remove some dead code. * No additional SIGINT is needed if int_pending() is already true. No functional change is intended. Modified: head/bin/sh/jobs.c Modified: head/bin/sh/jobs.c ============================================================================== --- head/bin/sh/jobs.c Sun Dec 12 21:26:12 2010 (r216399) +++ head/bin/sh/jobs.c Sun Dec 12 22:59:34 2010 (r216400) @@ -153,10 +153,8 @@ out: out2fmt_flush("sh: can't access mflag = 0; return; } - if (initialpgrp == -1) - initialpgrp = getpgrp(); - else if (initialpgrp != getpgrp()) { - killpg(0, SIGTTIN); + if (initialpgrp != getpgrp()) { + kill(0, SIGTTIN); continue; } } while (0); @@ -222,7 +220,6 @@ fgcmd(int argc __unused, char **argv) int bgcmd(int argc, char **argv) { - char s[64]; struct job *jp; do { @@ -233,8 +230,7 @@ bgcmd(int argc, char **argv) continue; restartjob(jp); jp->foreground = 0; - fmtstr(s, 64, "[%td] ", jp - jobtab + 1); - out1str(s); + out1fmt("[%td] ", jp - jobtab + 1); printjobcmd(jp); } while (--argc > 1); return 0; @@ -251,7 +247,7 @@ restartjob(struct job *jp) return; setcurjob(jp); INTOFF; - killpg(jp->ps[0].pid, SIGCONT); + kill(-jp->ps[0].pid, SIGCONT); for (ps = jp->ps, i = jp->nprocs ; --i >= 0 ; ps++) { if (WIFSTOPPED(ps->status)) { ps->status = -1; @@ -951,9 +947,7 @@ waitforjob(struct job *jp, int *origstat if (! JOBS || jp->state == JOBDONE) freejob(jp); if (int_pending()) { - if (WIFSIGNALED(status) && WTERMSIG(status) == SIGINT) - kill(getpid(), SIGINT); - else + if (!WIFSIGNALED(status) || WTERMSIG(status) != SIGINT) CLEAR_PENDING_INT; } #if JOBS