#BUGFIX by exept
class: OSProcess
added: #waitForShufflersToFinish
comment/format in:
#finishedWithSuccess
#waitUntilFinished
#waitUntilFinishedWithTimeout:
changed:
#execute
#setupShufflerForOutput:
#terminateShufflerProcesses:
--- a/OSProcess.st Wed Feb 26 01:27:28 2020 +0100
+++ b/OSProcess.st Wed Feb 26 01:28:43 2020 +0100
@@ -892,7 +892,6 @@
|data|
data := shuffledStream nextLine.
- "/ Transcript showCR:'got: ',data printString.
data notNil ifTrue:[
"/ Transcript showCR:'for: ',aStream printString.
aStream nextPutLine:data
@@ -900,6 +899,7 @@
].
] ifFalse:[
shuffledStream copyToEndInto:aStream.
+ aStream flush.
].
] on:WriteError do:[:ex |
"ignore"
@@ -969,6 +969,8 @@
!OSProcess methodsFor:'queries'!
finishedWithSuccess
+ "return true if so"
+
^ exitStatus notNil and:[exitStatus success].
!
@@ -997,12 +999,14 @@
Answer true if it successfully terminated,
false if it could not be started or terminated with error."
- ^ [
- self startProcess
- and:[
- self waitUntilFinished.
- self finishedWithSuccess.
- ].
+ |ok|
+
+ [
+ ok := self startProcess.
+ self waitUntilFinished.
+ ok := ok & self finishedWithSuccess.
+ self waitForShufflersToFinish
+
"if we come here, all streamsToClose have been closed
and all shuffler processses are terminated"
] ifCurtailed:[
@@ -1011,10 +1015,12 @@
pid notNil ifTrue:[
self terminateGroup.
].
+ self waitUntilFinished.
self
closeHelperStreams;
terminateShufflerProcesses.
].
+ ^ ok
"Modified: / 29-10-2018 / 15:59:33 / Claus Gittinger"
"Modified: / 31-10-2018 / 12:31:42 / Maren"
@@ -1223,10 +1229,25 @@
!OSProcess methodsFor:'waiting'!
+waitForShufflersToFinish
+ "return false if timedout; true if finished"
+
+ |processList|
+
+ "have to wait until the output shufflers shuffling command's outputs have finished their work"
+ processList := outputShufflerProcesses.
+ processList notNil ifTrue:[
+ processList do:[:eachProcess |
+ eachProcess waitUntilTerminated.
+ ].
+ outputShufflerProcesses := nil.
+ ].
+!
+
waitUntilFinished
<resource: #skipInDebuggersWalkBack>
- "wait with a veryy long timeout,
+ "wait with a veeeeeery long timeout,
in order that ProcessorScheduler>>#checkForEndOfDispatch recognizes
this waiting process as an user process which is still alive.
The timeout is meant to never occur!!"
@@ -1240,29 +1261,24 @@
!
waitUntilFinishedWithTimeout:timeout
- <resource: #skipInDebuggersWalkBack>
+ "return false if timedout; true if finished"
- |processList|
+ <resource: #skipInDebuggersWalkBack>
(finishSema waitWithTimeout:timeout) isNil ifTrue:[
"timed out"
- ^ nil.
+ ^ false.
].
"have to wait until the output shufflers shuffling command's outputs have finished their work"
- processList := outputShufflerProcesses.
- processList notNil ifTrue:[
- processList do:[:eachProcess |
- eachProcess waitUntilTerminated.
- ].
- outputShufflerProcesses := nil.
- ].
+ self waitForShufflersToFinish.
"command has finished and is no longer reading from its inputs"
inputShufflerProcesses notNil ifTrue:[
self terminateShufflerProcesses:inputShufflerProcesses.
inputShufflerProcesses := nil.
].
+ ^ true
"Modified: / 30-05-2018 / 13:57:39 / Claus Gittinger"
"Modified: / 01-11-2018 / 15:53:09 / Stefan Vogel"