What would you expect the return code of a process to be if the process is 
never executed? Note that the default value for an integer is 0, so if the 
return code is never set, then it remains 0 by default.

Shells, etc have their own defined error codes for this, and set the return 
code accordingly. For example, when invoking the shell using `poEvalCommand` 
(via the following code), the shell sets the return code to 127.
    
    
    import std/osproc
    import std/oserrors
    
    var command = "lsaaa -lah"
    
    try:
        let process = startProcess(command, options = {poUsePath, 
poParentStreams, poEvalCommand})
        echo "WAITING..."
        echo process.waitForExit()
    except OSError as e:
        echo "ERROR CODE:", e.errorCode
        echo OSErrorCode(e.errorCode)
        echo e.msg
    
    
    Run

Reply via email to