From 9624ca147909f29226260dd38468e5db4610c3b7 Mon Sep 17 00:00:00 2001 From: jilles Date: Sun, 12 Dec 2010 22:59:34 +0000 Subject: [PATCH] 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. --- bin/sh/jobs.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/bin/sh/jobs.c b/bin/sh/jobs.c index de813c25acd7..6a781ea13055 100644 --- a/bin/sh/jobs.c +++ b/bin/sh/jobs.c @@ -153,10 +153,8 @@ out: out2fmt_flush("sh: can't access tty; job control turned off\n"); 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 *origstatus) 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