Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

pclose - close pipe stream

&pagelevel(4)&pagelevel

Syntax

#include <stdio.h>

int pclose(FILE *stream); 

Description

pclose() closes the named stream that was opened by popen(), waits for the command
started by popen() to terminate, and returns its exit status. However, if the exit status is
unavailable to pclose(), then pclose() returns -1 and sets errno to ECHILD to report the
situation. This may occur if the application has already obtained the exit status by one of
the following functions:

  • wait()

  • waitpid() with a pid argument less than or equal to 0 or equal to the process ID of the
    command interpreter.

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

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

Return val.

Exit status of the command interpreter


if successful.

-1

if stream was not created by popen().

Errors

pclose() will fail if:

 

ECHILD

The exit status of the child process could not be determined.

 

Extension

 

EINVAL

An attempt was made to access a BS2000 file. (End)

Notes

pclose() is executed only for POSIX files.

See also

fork(), popen(), wait(), waitpid(), stdio.h.