In C, the pclose() function closes a stream that was opened by popen().
In C, the pclose()
function closes a stream that was opened by popen()
, waits for the command to terminate, and returns the termination status of the process that was running the command interpreter. However, if a call caused the termination status to be unavailable to pclose()
, then pclose()
returns -1 with errno
set to ECHILD
to report this situation. This can happen if the application calls one of the following functions:
wait()
waitpid()
with the pid argument of -1 or equal to the process ID of the command interpreter.
In any case, pclose()
does not return before the child process created by popen()
terminates.
If some error prevents the command interpreter from executing after the child process is created, the return value from pclose()
is as if the command language interpreter had terminated using exit(127)
or _exit(127)
.
Source: Man page for pclose() -- close pipe stream at mkSoftware