summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2012-07-10 08:42:44 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2012-07-10 08:42:44 +0000
commit8e2071059fc32b1a9e399868f122d810deebe2b3 (patch)
tree149f9dd75406ff0b6984452c2e589fec7bc20fc6
parentbea7d6ba76e17228d62c06e13386b5316aca100a (diff)
Restore termios and signal handlers before ~$ so ^C will kill child.
-rw-r--r--usr.bin/cu/command.c11
-rw-r--r--usr.bin/cu/cu.c7
2 files changed, 16 insertions, 2 deletions
diff --git a/usr.bin/cu/command.c b/usr.bin/cu/command.c
index 6d17897d393..a6d9b80b95d 100644
--- a/usr.bin/cu/command.c
+++ b/usr.bin/cu/command.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: command.c,v 1.2 2012/07/10 08:16:27 nicm Exp $ */
+/* $OpenBSD: command.c,v 1.3 2012/07/10 08:42:43 nicm Exp $ */
/*
* Copyright (c) 2012 Nicholas Marriott <nicm@openbsd.org>
@@ -46,6 +46,8 @@ pipe_command(void)
if (cmd == NULL || *cmd == '\0')
return;
+ restore_termios();
+
switch (pid = fork()) {
case -1:
err(1, "fork");
@@ -55,6 +57,11 @@ pipe_command(void)
_exit(1);
close(fd);
+ if (signal(SIGINT, SIG_DFL) == SIG_ERR)
+ _exit(1);
+ if (signal(SIGQUIT, SIG_DFL) == SIG_ERR)
+ _exit(1);
+
/* attach stdout to line */
if (dup2(line_fd, STDOUT_FILENO) == -1)
_exit(1);
@@ -69,6 +76,8 @@ pipe_command(void)
/* nothing */;
break;
}
+
+ set_termios();
}
void
diff --git a/usr.bin/cu/cu.c b/usr.bin/cu/cu.c
index 13d4e5b1273..ee87334b728 100644
--- a/usr.bin/cu/cu.c
+++ b/usr.bin/cu/cu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cu.c,v 1.2 2012/07/10 08:16:27 nicm Exp $ */
+/* $OpenBSD: cu.c,v 1.3 2012/07/10 08:42:43 nicm Exp $ */
/*
* Copyright (c) 2012 Nicholas Marriott <nicm@openbsd.org>
@@ -138,8 +138,13 @@ getopt:
err(1, "tcgetattr");
event_init();
+
signal_set(&sigterm_ev, SIGTERM, signal_event, NULL);
signal_add(&sigterm_ev, NULL);
+ if (signal(SIGINT, SIG_IGN) == SIG_ERR)
+ err(1, "signal");
+ if (signal(SIGQUIT, SIG_IGN) == SIG_ERR)
+ err(1, "signal");
set_termios();