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.
This commit is contained in:
parent
f041f6a7b7
commit
b036c75b4c
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=216400
@ -153,10 +153,8 @@ out: out2fmt_flush("sh: can't access tty; job control turned off\n");
|
|||||||
mflag = 0;
|
mflag = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (initialpgrp == -1)
|
if (initialpgrp != getpgrp()) {
|
||||||
initialpgrp = getpgrp();
|
kill(0, SIGTTIN);
|
||||||
else if (initialpgrp != getpgrp()) {
|
|
||||||
killpg(0, SIGTTIN);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} while (0);
|
} while (0);
|
||||||
@ -222,7 +220,6 @@ fgcmd(int argc __unused, char **argv)
|
|||||||
int
|
int
|
||||||
bgcmd(int argc, char **argv)
|
bgcmd(int argc, char **argv)
|
||||||
{
|
{
|
||||||
char s[64];
|
|
||||||
struct job *jp;
|
struct job *jp;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
@ -233,8 +230,7 @@ bgcmd(int argc, char **argv)
|
|||||||
continue;
|
continue;
|
||||||
restartjob(jp);
|
restartjob(jp);
|
||||||
jp->foreground = 0;
|
jp->foreground = 0;
|
||||||
fmtstr(s, 64, "[%td] ", jp - jobtab + 1);
|
out1fmt("[%td] ", jp - jobtab + 1);
|
||||||
out1str(s);
|
|
||||||
printjobcmd(jp);
|
printjobcmd(jp);
|
||||||
} while (--argc > 1);
|
} while (--argc > 1);
|
||||||
return 0;
|
return 0;
|
||||||
@ -251,7 +247,7 @@ restartjob(struct job *jp)
|
|||||||
return;
|
return;
|
||||||
setcurjob(jp);
|
setcurjob(jp);
|
||||||
INTOFF;
|
INTOFF;
|
||||||
killpg(jp->ps[0].pid, SIGCONT);
|
kill(-jp->ps[0].pid, SIGCONT);
|
||||||
for (ps = jp->ps, i = jp->nprocs ; --i >= 0 ; ps++) {
|
for (ps = jp->ps, i = jp->nprocs ; --i >= 0 ; ps++) {
|
||||||
if (WIFSTOPPED(ps->status)) {
|
if (WIFSTOPPED(ps->status)) {
|
||||||
ps->status = -1;
|
ps->status = -1;
|
||||||
@ -951,9 +947,7 @@ waitforjob(struct job *jp, int *origstatus)
|
|||||||
if (! JOBS || jp->state == JOBDONE)
|
if (! JOBS || jp->state == JOBDONE)
|
||||||
freejob(jp);
|
freejob(jp);
|
||||||
if (int_pending()) {
|
if (int_pending()) {
|
||||||
if (WIFSIGNALED(status) && WTERMSIG(status) == SIGINT)
|
if (!WIFSIGNALED(status) || WTERMSIG(status) != SIGINT)
|
||||||
kill(getpid(), SIGINT);
|
|
||||||
else
|
|
||||||
CLEAR_PENDING_INT;
|
CLEAR_PENDING_INT;
|
||||||
}
|
}
|
||||||
#if JOBS
|
#if JOBS
|
||||||
|
Loading…
Reference in New Issue
Block a user