Tcl Source Code

View Ticket
Login
Ticket UUID: 689835
Title: macosx: reading from write-only pipe hangs
Type: Bug Version: obsolete: 8.4.1
Submitter: das Created on: 2003-02-20 05:19:39
Subsystem: 27. Channel Types Assigned To: hobbs
Priority: 9 Immediate Severity:
Status: Closed Last Modified: 2003-02-21 09:40:01
Resolution: Fixed Closed By: hobbs
    Closed on: 2003-02-21 02:40:01
Description:
on Mac OS X, trying to read e.g. from stdout when it is a 
pipe will not fail as on other platforms but block forever in 
the recv() in TcpInputProc().

this has been a long standing very annoying bug that 
among others things interferes with the workings of 'make 
test', e.g. "test io-32.1" will hang when it tries to [read 
stdout] because stdout is a pipe when io.test is run from 
tests/all.tcl

I have now found an effective & simple workaround that 
AFAICT does not have any negative implications on other 
unices:

when creating a socket channel in Tcl_MakeFileChannel(), 
the mode argument cannot be passed to 
Tcl_MakeTcpClientChannel() as noted in the comments.
I've now added a static MakeTcpClientChannelMode() 
taking a mode argument and use this from 
Tcl_MakeFileChannel().
Tcl_MakeTcpClientChannel() simply calls through to 
MakeTcpClientChannelMode() with the default mode.

so for writeonly files like stdout, the channel will now be 
marked as writeonly even when it is based on a socket fd, 
and thus reading from the channel will fail before the recv() 
is ever attempted, thus working around the macosx 
problem.

c.f. attached patch for implementation.
User Comments: hobbs added on 2003-02-21 09:40:01:
Logged In: YES 
user_id=72656

in for 8.4.2.

das added on 2003-02-20 12:27:53:

File Added - 42947: tclUnixChan.diff

Logged In: YES 
user_id=90580

Jeff, 
could you possibly take a look at reviewing this? the changes 
are minor and shouldn't have any wider implications AFAICT.

it would be great if this could go into 8.4.2 as the broken 'make 
test' on macosx is really annoying...

Thanks

Attachments: