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 <RETURN>. 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 <std_disclaimer.h>