summaryrefslogtreecommitdiffstats
path: root/bin/sh/jobs.c
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2010-06-06 22:27:32 +0000
committerjilles <jilles@FreeBSD.org>2010-06-06 22:27:32 +0000
commitcaf58c06dccc18cc48b8c0e79badc9395c7c9028 (patch)
tree8e275d5bda0d45cee8f7a2b0af83efbd2c35459f /bin/sh/jobs.c
parent3bcf4834bbfb8c8c8023e0c832e654f827c1ff0d (diff)
downloadFreeBSD-src-caf58c06dccc18cc48b8c0e79badc9395c7c9028.zip
FreeBSD-src-caf58c06dccc18cc48b8c0e79badc9395c7c9028.tar.gz
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
Diffstat (limited to 'bin/sh/jobs.c')
-rw-r--r--bin/sh/jobs.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/bin/sh/jobs.c b/bin/sh/jobs.c
index d42848f..29939d1 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;
}
OpenPOWER on IntegriCloud