- wait #!optional pid-or-process nohangprocedure
Like process-wait, but nonblocking: Suspends the current process until the child process described by pid-or-process (either a numerical process ID or a scsh-process object) has terminated using the UNIX system call waitpid(). If pid-or-process is not given, then this procedure waits for any child process. If nohang is given and not #f then the current process is not suspended.
This procedure returns three values, in a different order from process-wait:
- Either the exit status, if the process terminated normally or the signal number that terminated/stopped the process.
- #t if the process exited normally or #f otherwise.
- pid or 0
All values are #f, if nohang is true and the child process has not terminated yet.
It is allowed to wait multiple times for the same process after it has completed, if you pass a process object. Process IDs can only be waited for once after they have completed and will cause an error otherwise.
This procedure is nonblocking, which means you can wait for a child in a thread and have the other threads continue to run; the process isn't suspended, but a signal handler will take care of unblocking the waiting thread.