1207 within the block. |
1207 within the block. |
1208 ActionBlock will be called with an OSProcessStatus as arg if the |
1208 ActionBlock will be called with an OSProcessStatus as arg if the |
1209 status of the OS process changes (e.g. the process terminates). |
1209 status of the OS process changes (e.g. the process terminates). |
1210 The method returns the value from aBlockReturningPid (i.e. a pid or nil)." |
1210 The method returns the value from aBlockReturningPid (i.e. a pid or nil)." |
1211 |
1211 |
1212 |pid wasBlocked exitStatus| |
1212 |pid wasBlocked| |
1213 |
1213 |
1214 "/ aBlock will be evaluated: |
1214 "/ aBlock will be evaluated: |
1215 "/ on unix: as soon as a SIGCHLD interrupt for pid has been received. |
1215 "/ on unix: as soon as a SIGCHLD interrupt for pid has been received. |
1216 "/ on win: as soon as a select for the pid handle returns |
1216 "/ on win: as soon as a select for the pid handle returns |
1217 |
1217 |
1218 OperatingSystem enableChildSignalInterrupts. "/ no-op in windows |
1218 OperatingSystem enableChildSignalInterrupts. "/ no-op in windows |
1219 wasBlocked := OperatingSystem blockInterrupts. |
1219 wasBlocked := OperatingSystem blockInterrupts. |
1220 "/ start the OS-Process |
1220 "/ start the OS-Process |
1221 pid := aBlockReturningPid value. |
1221 pid := aBlockReturningPid value. |
1222 pid notNil ifTrue:[ |
1222 pid notNil ifTrue:[ |
1223 osChildExitActions at:pid put:actionBlock. |
1223 osChildExitActions at:pid put:actionBlock. |
1224 ]. |
|
1225 "check for a race, that SIGCHILD was received before we could register the actionBlock" |
|
1226 exitStatus := OperatingSystem childProcessWait:false pid:pid. |
|
1227 exitStatus notNil ifTrue:[ |
|
1228 self unmonitorPid:pid. |
|
1229 wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
|
1230 actionBlock value:exitStatus. |
|
1231 ]. |
1224 ]. |
1232 wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
1225 wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
1233 ^ pid |
1226 ^ pid |
1234 |
1227 |
1235 "Created: / 25.3.1997 / 10:54:56 / stefan" |
1228 "Created: / 25.3.1997 / 10:54:56 / stefan" |