Greetings Pharoers!
I have following problem when using OSSubprocess library. If I run a method that uses code below, it fails: Error: Error: posix_spawn(), code: 9, description: Bad file descriptor
Any thoughts, hints are welcome!
My code redirects stdout, stdin in order to catch system outputs from inside of Pharo.
Subprocess code does following:
OSUnixSubprocess>>runAndWaitWithStdOutputself redirectStdout; redirectStderr; runAndWaitOnExitDo: [ :termProcess :outString :errString | termProcess isSuccess ifTrue: [ ^ outString ] ifFalse: [ "commands to handle ex message here" ] ]
Now if I run, it fails:
Error: Error: posix_spawn(), code: 9, description: Bad file descriptor
OSSUnixSystemAccessor(Object)>>error:
OSSUnixSystemAccessor>>strerror:message:
OSSUnixSubprocess>>internalRun
[ self internalRun ] in OSSUnixSubprocess>>run in Block: [ self internalRun ]
BlockClosure>>ensure:
OSSUnixSubprocess>>run
OSSUnixSubprocess>>runAndWaitOnExitDo:
OSSUnixSubprocess>>runAndWaitWithStdOutput
...
..
.
PhLImageProcessListCliCommand(PhLCliCommand)>>executeOSShellCommand
So it seems that OSUnixSubprocess uses some file that remains opened probably in OS?
Command that is passed to OSSubprocess is generated by args:
^ Array with: 'echo' with: '-n' with: ('$(pgrep -a -f Pharo | grep ''.image'' | grep -v ''.bash''| grep -v {1})' format: {self currentVMPid asString})