Open System Services Library Calls Reference Manual (G06.27+, H06.04+)
OSS Library Calls (n - r) popen(3)
NOTES
Programs using the popen() function to invoke an output filter should beware of possible
deadlock caused by output data remaining in the program’s buffer. This can be avoided either by
using the setbuf( ) function to ensure that the output stream is unbuffered or by using the fflush( )
function to ensure that all buffered data is flushed before you call the pclose( ) function.
CAUTIONS
If the original processes and the process started with the popen( ) function concurrently read or
write a common file, neither should use buffered I/O. If they do, the results are unpredictable.
RETURN VALUES
Upon successful completion, the popen( ) function returns a pointer to the FILE structure for the
opened stream. If files or processes could not be created, the popen( ) function returns a null
pointer. If the mode parameter is invalid, the popen( ) function returns a null string and sets
errno to [EINVAL].
ERRORS
If any of the following conditions occurs, the popen( ) function sets errno to the corresponding
value:
[EINVAL] The mode parameter is invalid.
[ENOMEM] The system has insufficient resources.
[ENOTOSS] The calling process was not an OSS process.
The popen( ) function can also return errors from its calls to the fork() and pipe() functions.
RELATED INFORMATION
Functions: exec(2), fclose(3), fopen(3), fork(2), pclose(3), pipe(2), setbuf(3).
STANDARDS CONFORMANCE
The following are HP extensions to the XPG4 Version 2 specification:
• The function can return the errno value [ENOTOSS].
527187-004 Hewlett-Packard Company 5−31