The return value is a Result struct, which has two members: reason and status. The reason can take the following values:
Process.Result.Exit: the child process exited normally; status has the process' return code.
Process.Result.Signal: the child process was killed by a signal; status has the signal number that killed the process.
Process.Result.Stop: the process was stopped; status has the signal number that was used to stop the process.
Process.Result.Continue: the process had been previously stopped and has now been restarted; status has the signal number that was used to continue the process.
Process.Result.Error: We could not properly wait on the child process; status has the errno value if the process was running and -1 if not.
Remarks: You can only call wait() on a running process once. The Signal, Stop and Continue reasons will only be returned on POSIX-compatible platforms. Calling wait() will not clean the pipes as the parent process may still want the remaining output. It is however recommended to call close() when no more content is expected, as this will close the pipes.
Unconditionally wait for a process to end and return the reason and status code why the process ended.