AssignStream doesn't report it if the executable path isn't found
Original Reporter info from Mantis: Adriaan van Os
-
Reporter name: Adriaan van Os
Original Reporter info from Mantis: Adriaan van Os
- Reporter name: Adriaan van Os
Description:
AssignStream doesn't return ProcessID -1 if the executable isn't found. Instead a positive ProcessID is returned, suggesting a valid ProcessID, for example if I try to execute ''/bin/lsxxx" instead of "/bin/ls".
I experimented with theWaitID := fpWaitPid( theProcessID, theStatus, WNOHANG); following a suggestion by Seth Grover in fpc-pascal@lists.freepascal.org of 27-07-2009 15:27. When debugging, this indeed catches the error by returning theWaitID = theProcessID and wexitStatus( theStatus) = 127.
However, when running my test program at full speed, theWaitID= 0 was returned for a non-existing executable path like ''/bin/lsxxx" .
So, I don't see how this can be solved in application code. Also, I feel that AssignStream should handle this, as the documentation says:
"The function returns the process ID of the spawned process, or -1 in case of error."
Mantis conversion info:
- Mantis ID: 34499
- OS: OS X
- OS Build: 10.8.5
- Platform: Darwin
- Version: 3.0.4
- Fixed in version: 3.3.1
- Fixed in revision: 40548 (#d49510cc)
- Target version: 3.2.0