Tcl Source Code

View Ticket
Login
Ticket UUID: 219149
Title: bad interaction of input redirect from named pipe with backg
Type: Bug Created on: 2000-10-26 05:02:20
Submitter: nobody Assigned to: andreas_kupries
Subsystem: 27. Channel Types Severity:
Priority: 5 Medium Last modified: 2013-03-24 22:27:40
Status: Open Closed by:
Resolution: None Closed on:
Version: obsolete: 8.0p2
Description:
OriginalBugID: 950 Bug
Version: 8.0p2
SubmitDate: '1998-12-14'
LastModified: '1999-12-07'
Severity: SER
Status: Assigned
Submitter: pat
ChangedBy: hobbs
OS: Linux
Machine: Other
FixedDate: '2000-10-25'
ClosedDate: '2000-10-25'


Name: Harald

ReproducibleScript:
Run the following script.

#!/bin/sh
# exec tclsh8.0 "$0" 

exec mkfifo fifo
puts [exec cat <fifo >@stdout &]

ObservedBehavior:
Although there is an `&' at the end
of the exec-arguments, the exec does
not return.

DesiredBehavior:
If `&' is at the end of exec-args,
exec should always return soon, independent of input redirection.


There is a not-so-perfect workaround. The fifo can be opened with NONBLOCK and the handle to the opened fifo can be used to redirect input. However then the child-process sees a non-blocking
input channel, which is probably not what was intended.
--
Verified in 8.2.2 on Solaris. 
-- 12/07/1999 hobbs
User Comments:
andreas_kupries added on 2001-09-12 03:00:52:
Logged In: YES 
user_id=75003

Harald = <[email protected]> ...
Harald Kirsch, author of 'bras'.

dgp added on 2002-07-06 03:34:44:
Logged In: YES 
user_id=80530

Is this still a valid bug report?

If so, it may be the oldest Open bug in Tcl.

mistachkin added on 2002-10-20 02:55:07:
Logged In: YES 
user_id=113501

Tested and verified on 

FreeBSD 4.7-STABLE FreeBSD 4.7-STABLE #1: Thu Oct 10 
13:55:32 EDT 2002 /usr/obj/usr/src/sys/GENERIC i386

dgp added on 2013-03-24 22:15:55:
oldest open bug in Tcl still hanging in there.

ferrieux added on 2013-03-24 22:27:40:
To me, [exec &] does the best compromise between asynchronicity and immediate reporting of lethal failures.

The most popular "immediate failure" that [exec &] reports synchronously is one about the executable (not found, or improper rights). Nobody complains about that.

In the same logic, it also reports *synchronously* about a failure to do the redirections. This is done by putting the open()  *before* the sync point. Again, everybody is happy about this behavior I guess.

Then, in the specific case of a named pipe with nobody yet on the other end, this very open() will block. That's a necessary consequence of the above. It may surprise people because it is unlike the Bourne Shell, where the open()s lay completely within the forked process and no rendezvous will propagate the blocking. But I still think this rendezvous is a superior feature of Tcl, geared towards better error reporting.

So I'd rather document the gotcha than overhaul a sane behavior.