# HG changeset patch # User Stefan Vogel # Date 1169817420 -3600 # Node ID 5cf689c14989d786008aa8725ebf2ea81d4957d5 # Parent ed621d39a311a39f024237801c0d333596125f0b Fix race condition in PipeStream. This race could falsly report io errors when forking subprocesses. diff -r ed621d39a311 -r 5cf689c14989 PipeStream.st --- a/PipeStream.st Wed Jan 24 19:55:33 2007 +0100 +++ b/PipeStream.st Fri Jan 26 14:17:00 2007 +0100 @@ -566,7 +566,7 @@ |blocked pipeFdArray execFdArray execFd myFd shellAndArgs shellPath shellArgs mbx mbxName - realCmd execDirectory tmpComFile nullOutput| + realCmd execDirectory tmpComFile nullOutput resultPid| filePointer notNil ifTrue:[ "the pipe was already open ... @@ -665,7 +665,8 @@ blocked := OperatingSystem blockInterrupts. - pid := Processor + "beware: pid may change if subprocess is fast" + pid := resultPid := Processor monitor:[ OperatingSystem exec:shellPath @@ -705,7 +706,7 @@ nullOutput close ]. - pid notNil ifTrue:[ + resultPid notNil ifTrue:[ "successfull creation of subprocesss" OperatingSystem isVMSlike ifTrue:[ "/ @@ -734,7 +735,7 @@ OperatingSystem unblockInterrupts ]. - (pid isNil or:[lastErrorNumber notNil]) ifTrue:[ + (resultPid isNil or:[lastErrorNumber notNil]) ifTrue:[ " the pipe open failed for some reason ... ... this may be either due to an invalid command string, @@ -788,7 +789,7 @@ !PipeStream class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libbasic/PipeStream.st,v 1.105 2007-01-19 13:50:01 cg Exp $' + ^ '$Header: /cvs/stx/stx/libbasic/PipeStream.st,v 1.106 2007-01-26 13:17:00 stefan Exp $' ! ! PipeStream initialize!