1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-10-20 02:38:43 +00:00

sh: Pass through SIGINT from a child if interactive and job control

is enabled.

This already worked if without job control.

In either case, this depends on it that a process that terminates due to
SIGINT exits on it (so not with status 1, or worse, 0).

Example:
  sleep 5; echo continued
This does not print "continued" any more if sleep is aborted via ctrl+c.

MFC after:	1 month
This commit is contained in:
Jilles Tjoelker 2010-06-06 22:27:32 +00:00
parent 8ce4a9a255
commit f3d893fcde
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=208881

View File

@ -866,6 +866,7 @@ waitforjob(struct job *jp, int *origstatus)
{
#if JOBS
pid_t mypgrp = getpgrp();
int propagate_int = jp->jobctl && jp->foreground;
#endif
int status;
int st;
@ -903,6 +904,11 @@ waitforjob(struct job *jp, int *origstatus)
else
CLEAR_PENDING_INT;
}
#if JOBS
else if (rootshell && iflag && propagate_int &&
WIFSIGNALED(status) && WTERMSIG(status) == SIGINT)
kill(getpid(), SIGINT);
#endif
INTON;
return st;
}