Discussion:
[ast-developers] ksh93v- 2013-08-27 has broken pipe IO
Dr. Werner Fink
2013-09-05 08:56:49 UTC
Permalink
Hi,

during debugging the `set -k' problem of the 93u+ 2012-08-01 I've
ported back changes of the current ksh93v- tree, that is

abuild at noether:/home/abuild/rpmbuild/BUILD/ksh93> set -k
abuild at noether:/home/abuild/rpmbuild/BUILD/ksh93> d=`/bin/echo x y=$(/bin/echo z)`; echo $d x y=z
x

... with the backport the output becomes correct:

abuild at noether:/home/abuild/rpmbuild/BUILD/ksh93> set -k
abuild at noether:/home/abuild/rpmbuild/BUILD/ksh93> d=`/bin/echo x y=$(/bin/echo z)`; echo $d x y=z
x x

but with this backport the ksh93u+ 2012-08-01 as well as the original
ksh93v- 2013-08-27 both have broken pipe IO handling for external
commands:

abuild at noether:/home/abuild/rpmbuild/BUILD/ksh93> echo | echo `/usr/bin/date`

abuild at noether:/home/abuild/rpmbuild/BUILD/ksh93>

... note that with the `date' builtin of the ksh93v- 2013-08-27 it works
but the ksh93u+ 2012-08-01 does not have such a builtin.

For ksh93v- 2013-08-27 an strace with

# strace -s 256 -f -e write,read -p 24282

shows

Process 24282 attached - interrupt to quit
read(0, "\r", 80) = 1
write(2, "\n", 1) = 1
read(3, "", 65536) = 0
write(3, "echo | echo `/usr/bin/date`\n\0\0", 30) = 30
Process 24298 attached
[pid 24298] write(1, "\n", 1) = 1
Process 24298 detached
Process 24299 attached (waiting for parent)
Process 24299 resumed (parent 24282 ready)
[pid 24282] --- {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=24298, si_status=0, si_utime=0, si_stime=0} (Child exited) ---
[pid 24282] read(4, "", 65536) = 0
[pid 24282] write(1, "\n", 1) = 1
Process 24282 suspended
[pid 24299] read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\34\2\0\0\0\0\0@\0\0\0\0\0\0\0\270\244\32\0\0\0\0\0\0\0\0\0@\0008\0\n\0@\0F\0C\0\6\0\0\0\5\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0000\2\0\0\0\0\0\0000\2\0\0\0\0\0\0\10\0\0\0\0\0\0\0\3\0\0\0\4\0\0\0\220\3\27\0\0\0\0\0\220\3\27\0\0\0\0\0\220\3\27\0\0\0\0\0\34\0\0\0\0\0\0\0\34\0\0\0\0\0\0\0\20\0\0\0\0\0\0\0\1\0\0\0\5\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0tF\32\0\0\0\0\0tF\32\0\0\0\0\0\0\0 \0\0\0\0\0\1\0\0\0\6\0\0\0\360F\32\0\0\0\0\0\360F:\0\0\0\0\0"..., 832) = 832
[pid 24299] write(1, "Thu Sep 5 08:49:04 UTC 2013\n", 29) = 29
Process 24282 resumed
Process 24299 detached
--- {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=24299, si_status=0, si_utime=0, si_stime=0} (Child exited) ---
read(3, "", 65536) = 0
write(2, "abuild at noether:/home/abuild/rpmbuild/BUILD/ksh93> ", 50) = 50

which leads to the conclusion that the external command has been
disconnected from stdout or that the stdout is not connected to
the terminal or that a pipe/tmpfile redirection is missed. Indeed
if I use the command

echo | echo `ls -l /proc/self/fd/1`

I see in the strace

Process 24282 suspended
[pid 24436] write(1, "lrwx------ 1 abuild abuild 64 Sep 5 08:54 /proc/self/fd/1 -> /tmp/sfe0b1PTkm.TzO (deleted)\n", 92) = 92
Process 24282 resumed
Process 24436 detached



Werner
--
"Having a smoking section in a restaurant is like having
a peeing section in a swimming pool." -- Edward Burr
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 828 bytes
Desc: not available
URL: <http://lists.research.att.com/pipermail/ast-developers/attachments/20130905/bd8039d4/attachment.sig>
Loading...