The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group

 NAME

pclose - close a pipe stream to or from a process

 SYNOPSIS



#include <stdio.h>

int pclose(FILE *stream);

 DESCRIPTION

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 language 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:

In any case, pclose() will not return before the child process created by popen() has terminated.

If the command language interpreter cannot be executed, the child termination status returned by pclose() will be as if the command language interpreter terminated using exit(127) or _exit(127).

The pclose() function will not affect the termination status of any child of the calling process other than the one created by popen() for the associated stream.

If the argument stream to pclose() is not a pointer to a stream created by popen(), the result of pclose() is undefined.

 RETURN VALUE

Upon successful return, pclose() returns the termination status of the command language interpreter. Otherwise, pclose() returns -1 and sets errno to indicate the error.

 ERRORS

The pclose() function will fail if:
[ECHILD]
The status of the child process could not be obtained, as described above.

 EXAMPLES

None.

 APPLICATION USAGE

None.

 FUTURE DIRECTIONS

None.

 SEE ALSO

fork(), popen(), waitpid(), <stdio.h>.

DERIVATION

Derived from Issue 1 of the SVID.

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]