Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:69160 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 93572 invoked from network); 17 Sep 2013 00:27:24 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Sep 2013 00:27:24 -0000 Authentication-Results: pb1.pair.com header.from=addw@phcomp.co.uk; sender-id=permerror Authentication-Results: pb1.pair.com smtp.mail=addw@phcomp.co.uk; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain phcomp.co.uk designates 78.32.209.33 as permitted sender) X-PHP-List-Original-Sender: addw@phcomp.co.uk X-Host-Fingerprint: 78.32.209.33 freshmint.phcomp.co.uk Received: from [78.32.209.33] ([78.32.209.33:54128] helo=mint.phcomp.co.uk) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 50/76-57385-AE1A7325 for ; Mon, 16 Sep 2013 20:27:23 -0400 Received: from addw by mint.phcomp.co.uk with local (Exim 4.72) (envelope-from ) id 1VLj8R-0008Ba-D7 for internals@lists.php.net; Tue, 17 Sep 2013 01:27:19 +0100 Date: Tue, 17 Sep 2013 01:27:19 +0100 To: internals@lists.php.net Message-ID: <20130917002719.GM3919@phcomp.co.uk> Mail-Followup-To: internals@lists.php.net References: <20130914114540.GF3919@phcomp.co.uk> <523763A1.2090607@divbyzero.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <523763A1.2090607@divbyzero.net> Organization: Parliament Hill Computers Ltd User-Agent: Mutt/1.5.20 (2009-12-10) Subject: Re: [PHP-DEV] PHP CLI setting cooked terminal mode From: addw@phcomp.co.uk (Alain Williams) On Mon, Sep 16, 2013 at 10:01:37PM +0200, Martin Jansen wrote: > On 14.09.13 13:45, Alain Williams wrote: > > ./myScript | less > > > > Since less is an interactive program it puts the terminal into 'raw' mode so > > that it can read characters one at a time. However, when I do the above I find > > that the commands that I type to less are echoed back to me and not acted on > > until I type . This is not as it should be. > > > > If I run the script under strace I see: > > > > ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0 > > ioctl(0, SNDCTL_TMR_STOP or TCSETSW, {B38400 opost isig icanon echo ...}) = 0 > > > > What is happening is that PHP is putting the terminal into cooked mode. > > Are you sure it is PHP that's doing this? There are basically no calls > to ioctl() (or tcsetattr() for that matter) outside of ext/ at all. I have done a bit of digging and suspect that this happens as part of readline initialisation. phpinfo() reports: --without-readline but then: Additional Modules Module Name readline sysvsem sysvshm /usr/lib64/libedit.so.0 The system calls at about the time that it does the ioctl() on stdin are: brk(0x2b18000) = 0x2b18000 ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0 rt_sigprocmask(SIG_BLOCK, [WINCH], [], 8) = 0 ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0 stat("/home/addw/.terminfo", 0x7fff0ec06750) = -1 ENOENT (No such file or directory) stat("/etc/terminfo", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 access("/etc/terminfo/x/xterm", R_OK) = -1 ENOENT (No such file or directory) stat("/usr/share/terminfo", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 access("/usr/share/terminfo/x/xterm", R_OK) = 0 open("/usr/share/terminfo/x/xterm", O_RDONLY) = 3 read(3, "\32\0010\0&\0\17\0\235\1l\5xterm|xterm terminal"..., 4097) = 3258 close(3) = 0 ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0 ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0 ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0 ioctl(1, TIOCGWINSZ, {ws_row=65, ws_col=237, ws_xpixel=0, ws_ypixel=0}) = 0 ioctl(0, TIOCGWINSZ, {ws_row=65, ws_col=237, ws_xpixel=0, ws_ypixel=0}) = 0 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0 ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0 ioctl(0, SNDCTL_TMR_STOP or TCSETSW, {B38400 opost isig icanon echo ...}) = 0 rt_sigprocmask(SIG_BLOCK, [HUP INT QUIT TERM CONT STOP TSTP WINCH], [], 8) = 0 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0 open("/home/addw/.editrc", O_RDONLY) = -1 ENOENT (No such file or directory) -- Alain Williams Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer. +44 (0) 787 668 0256 http://www.phcomp.co.uk/ Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php #include