Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 16 Sep 2009 19:00:58 -0700
From:      Alfred Perlstein <alfred@freebsd.org>
To:        hackers@freebsd.org
Cc:        peter@freebsd.org
Subject:   script(1) issue/question
Message-ID:  <20090917020058.GD21946@elvis.mu.org>

next in thread | raw e-mail | index | archive | help

--s5/bjXLgkIwAv6Hi
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

[[ peter cc'd cause he seemed to add the original
   "exec a non-shell option" to script(1) ]]

Hello all,

I noticed that when running "script" and passing a program
to exec that ^Z does not seem to work (although ^C does).

I'm trying to figure a workaround and what I was going to
do was add ISIG to the term flags when spawning a non-shell
utility.

(should I also check /etc/shells to help preserve POLA
further?)

Any pointers on this?

Would this be a good idea, or a bad idea?  Terminal gurus
give me a hand please! :)

please ignore the sigflg part at the top for now, prepping
for possible cli option to avoid POLA breakage.

Is there a way to detect ^Z or other terminal signals and propogate
them to the child in a better way?

-- 
- Alfred Perlstein
.- AMA, VMOA #5191, 03 vmax, 92 gs500, 85 ch250
.- FreeBSD committer

--s5/bjXLgkIwAv6Hi
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment; filename="script1.diff"

Index: script.c
===================================================================
--- script.c	(revision 195826)
+++ script.c	(working copy)
@@ -68,6 +68,7 @@
 int	child;
 const char *fname;
 int	qflg, ttyflg;
+int	sigflg;
 
 struct	termios tt;
 
@@ -104,6 +105,9 @@
 		case 'k':
 			kflg = 1;
 			break;
+		case 'S':
+			sigflg = 1;
+			break;
 		case 't':
 			flushtime = atoi(optarg);
 			if (flushtime < 0)
@@ -241,11 +245,20 @@
 doshell(char **av)
 {
 	const char *shell;
+	struct termios rtt;
 
 	shell = getenv("SHELL");
 	if (shell == NULL)
 		shell = _PATH_BSHELL;
 
+	if (av[0]) {
+		/* enable signals for non-shell programs */
+		rtt = tt;
+		cfmakeraw(&rtt);
+		rtt.c_lflag &= ~ECHO;
+		rtt.c_lflag |= ISIG;
+		(void)tcsetattr(STDIN_FILENO, TCSAFLUSH, &rtt);
+	}
 	(void)close(master);
 	(void)fclose(fscript);
 	login_tty(slave);

--s5/bjXLgkIwAv6Hi--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090917020058.GD21946>