From owner-freebsd-hackers@FreeBSD.ORG Thu Sep 17 02:00:58 2009 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 85AE3106566C for ; Thu, 17 Sep 2009 02:00:58 +0000 (UTC) (envelope-from bright@elvis.mu.org) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.freebsd.org (Postfix) with ESMTP id 715828FC0C for ; Thu, 17 Sep 2009 02:00:58 +0000 (UTC) Received: by elvis.mu.org (Postfix, from userid 1192) id 250E41A3C5D; Wed, 16 Sep 2009 19:00:58 -0700 (PDT) Date: Wed, 16 Sep 2009 19:00:58 -0700 From: Alfred Perlstein To: hackers@freebsd.org Message-ID: <20090917020058.GD21946@elvis.mu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="s5/bjXLgkIwAv6Hi" Content-Disposition: inline User-Agent: Mutt/1.4.2.3i Cc: peter@freebsd.org Subject: script(1) issue/question X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Sep 2009 02:00:58 -0000 --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--