Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion repository/OSSubprocess/OSSUnixSubprocess.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,10 @@ OSSUnixSubprocess >> isComplete [
{ #category : 'status' }
OSSUnixSubprocess >> isRunning [
"Answers whether the process is still running or not (to our best knowledge)"
^ pid notNil and: [ self isComplete not ]

^ pid notNil and: [
self isComplete not and: [
OSSVMProcess vmProcess isChildRunning: pid ] ]
]

{ #category : 'status' }
Expand Down
20 changes: 19 additions & 1 deletion repository/OSSubprocess/OSSVMProcess.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ OSSVMProcess >> finalizePreviousSession [
self activeChildren do: [ :each | each stopWaiting ]
]

{ #category : 'childs management' }
OSSVMProcess >> includesChildPid: aPid [

^ childProcessList anySatisfy: [ :process | process pid = aPid ]
]

{ #category : 'initialize - release' }
OSSVMProcess >> initialize [
"Set my instance variables to reflect the state of the OS process in which
Expand Down Expand Up @@ -259,6 +265,17 @@ OSSVMProcess >> initializeSignalHandlers [

]

{ #category : 'child watching' }
OSSVMProcess >> isChildRunning: childPid [
"Use waitpid with WNOHANG option to know if the child process is running.
See: https://man7.org/linux/man-pages/man3/wait.3p.html"

^ (self
primitiveWaitpid: childPid
statusPointer: nil
options: WNOHANG) = 0
]

{ #category : 'cwd' }
OSSVMProcess >> lockCwdWithValue: cwdNewValue encoding: encoding during: aBlock [
"This method is a complete hack in order to support a #cmd: option in OSSUnixSubprocess.
Expand Down Expand Up @@ -306,7 +323,8 @@ OSSVMProcess >> pid [

{ #category : 'child watching' }
OSSVMProcess >> primitiveWaitpid: aProcessId statusPointer: statusPointer options: optionBits [

"See: https://linux.die.net/man/2/waitpid"

^ self ffiCall: #( int waitpid(int aProcessId, void* statusPointer, int optionBits) )
]

Expand Down
Loading