Andreas Leitgeb <avl@logic.at> wrote:
Is there any special logic within tcl, when stdin & -out haveI can now reproduce it on linux (originally it showed on AIX, but
been closed? maybe, if next command is "exec" ?
apparently isn't specific to it)
simple Test-Script:
close stdin; close stdout
exec true
[...]
Is there any special logic within tcl, when stdin & -out have
been closed? maybe, if next command is "exec" ?
After some more experiments, I've now created this ticket:
https://core.tcl-lang.org/tcl/tktview/21dbc600ae0a005a7f879a05580550a8da257b14
so, this thread here is now obsolete.
If standard input is not redirected with “<”, “<<” or “<@” then the standard input for the first command in the pipeline is taken
from the application's current standard input.
On 12/6/2022 6:59 AM, Andreas Leitgeb wrote:
After some more experiments, I've now created this ticket:
https://core.tcl-lang.org/tcl/tktview/21dbc600ae0a005a7f879a05580550a8da257b14
so, this thread here is now obsolete.
I wonder if this is really a "bug". From the documentation page for exec:
If standard input is not redirected with “<”, “<<” or “<@” then >> the standard input for the first command in the pipeline is taken
from the application's current standard input.
You have closed both stdin and stdout; but exec needs those as well as
sterr. The above paragraph also explains the work-around you have discovered: you are simply redirecting it to somewhere else.
Good point, but then why does it also depend on stdout having been
closed as well, to trigger that behaviour?
If I merely close stdin, or close both and reopen stdin from /dev/null
no hang happens.
Neither, if I close stdout, open /dev/null, then close stdin: no hang.
In these cases, missing stdin but not missing stdout, the child process
gets started fine without an fd 0, so exec doesn't really seem to depend specifically on a valid stdin for starting new processes.
It really seems like there is some hardcoded special case: if the pipe returns the endpoint-fds as [0, 1], then do something "unoptimal."
If standard output has not been redirected then the exec command returns
the standard output from the last command in the pipeline, unless “2>@1” was specified, in which case standard error is included as well.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 307 |
Nodes: | 16 (3 / 13) |
Uptime: | 59:15:32 |
Calls: | 6,915 |
Calls today: | 5 |
Files: | 12,379 |
Messages: | 5,431,064 |