svn commit: r208881 - head/bin/sh

Jilles Tjoelker jilles at FreeBSD.org
Sun Jun 6 22:27:33 UTC 2010


Author: jilles
Date: Sun Jun  6 22:27:32 2010
New Revision: 208881
URL: http://svn.freebsd.org/changeset/base/208881

Log:
  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

Modified:
  head/bin/sh/jobs.c

Modified: head/bin/sh/jobs.c
==============================================================================
--- head/bin/sh/jobs.c	Sun Jun  6 21:19:04 2010	(r208880)
+++ head/bin/sh/jobs.c	Sun Jun  6 22:27:32 2010	(r208881)
@@ -866,6 +866,7 @@ waitforjob(struct job *jp, int *origstat
 {
 #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 *origstat
 		else
 			CLEAR_PENDING_INT;
 	}
+#if JOBS
+	else if (rootshell && iflag && propagate_int &&
+			WIFSIGNALED(status) && WTERMSIG(status) == SIGINT)
+		kill(getpid(), SIGINT);
+#endif
 	INTON;
 	return st;
 }


More information about the svn-src-head mailing list