Andreas Leitgeb <
[email protected]> wrote:
Is there any special logic within tcl, when stdin & -out have
been closed? maybe, if next command is "exec" ?
I can now reproduce it on linux (originally it showed on AIX, but
apparently isn't specific to it)
simple Test-Script:
close stdin; close stdout
exec true
exit
The strace-output starting from the "close"s:
close(0) = 0
close(1) = 0
pipe([0, 1]) = 0
fcntl(0, F_SETFD, FD_CLOEXEC) = 0
fcntl(1, F_SETFD, FD_CLOEXEC) = 0
stat("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=12288, ...}) = 0 access("/tmp", W_OK) = 0
getpid() = 4239
openat(AT_FDCWD, "/tmp/tcl_kEjgNd", O_RDWR|O_CREAT|O_EXCL, 0600) = 3 unlink("/tmp/tcl_kEjgNd") = 0
fcntl(3, F_SETFD, FD_CLOEXEC) = 0
pipe([4, 5]) = 0
fcntl(4, F_SETFD, FD_CLOEXEC) = 0
fcntl(5, F_SETFD, FD_CLOEXEC) = 0
clone(child_stack=NULL,
flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f8497acda10) = 4240
close(5) = 0
read(4, "", 223) = 0
close(4) = 0
read(0, 0x561f2dd4e4f8, 4096) = ? ERESTARTSYS (To be restarted
if SA_RESTART is set)
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=4240,
si_uid=1000, si_status=0, si_utime=0, si_stime=0} ---
read(0,
The strace output on linux gives some more information, than truss on
AIX, namely that the main process starts reading the pipe even before
the child-process' exit is reported as SIGCHLD.
If I comment out the initial "close"s - any(!) of them - then all is fine:
the pipe gets created on higher fds, and the "read" that previously hung,
now immediately returns "". Then the pipe gets closed, and the exit done.
So, the question is no longer "Why is it reading from the pipe?"
but:
Why is there *no* other thread writing to it,
exactly if *both* stdin&stdout were previously closed?"
Also, I've now found a workaround: If I open /dev/null right after the
two closes, then the rest appears to work again.
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)