From f3d893fcde6df70d532ef613bf843d4b09bbaebf Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Sun, 6 Jun 2010 22:27:32 +0000 Subject: [PATCH] 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 --- bin/sh/jobs.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bin/sh/jobs.c b/bin/sh/jobs.c index d42848fd990..29939d1c1da 100644 --- a/bin/sh/jobs.c +++ b/bin/sh/jobs.c @@ -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; }