Open System Services Library Calls Reference Manual (G06.28+, H06.05+)

OSS Library Calls (n - r) popen(3)
NOTES
Programs using the popen() function to invoke an output lter should beware of possible
deadlock caused by output data remaining in the programs buffer. This can be avoided either by
using the setbuf( ) function to ensure that the output stream is unbuffered or by using the fush( )
function to ensure that all buffered data is ushed 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 le, 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 les 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 insufcient 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 specication:
The function can return the errno value [ENOTOSS].
527187-007 Hewlett-Packard Company 537