|
|
1.1 ! root 1: .TH POPEN 3 "18 July 1983" ! 2: .SH NAME ! 3: popen, pclose \- initiate I/O to/from a process ! 4: .SH SYNOPSIS ! 5: .B #include <stdio.h> ! 6: .PP ! 7: .SM ! 8: .B FILE ! 9: .B *popen(command, type) ! 10: .br ! 11: .B char *command, *type; ! 12: .PP ! 13: .B pclose(stream) ! 14: .br ! 15: .SM ! 16: .B FILE ! 17: .B *stream; ! 18: .SH DESCRIPTION ! 19: The arguments to ! 20: .I popen ! 21: are pointers to null-terminated strings containing respectively a ! 22: shell command line and an I/O mode, either "r" for reading or "w" for ! 23: writing. It creates a pipe between the calling process and ! 24: the command to be executed. The value returned is a stream pointer that ! 25: can be used (as appropriate) to write to the standard input ! 26: of the command or read from its standard output. ! 27: .PP ! 28: A stream opened by ! 29: .I popen ! 30: should be closed by ! 31: .IR pclose , ! 32: which waits for the associated process to terminate ! 33: and returns the exit status of the command. ! 34: .PP ! 35: Because open files are shared, a type "r" command may be used as an input ! 36: filter, and a type "w" as an output filter. ! 37: .SH "SEE ALSO" ! 38: pipe(2), ! 39: fopen(3S), ! 40: fclose(3S), ! 41: system(3), ! 42: wait(2), ! 43: sh(1) ! 44: .SH DIAGNOSTICS ! 45: .I Popen ! 46: returns a null pointer if files or processes cannot be created, or the shell ! 47: cannot be accessed. ! 48: .PP ! 49: .I Pclose ! 50: returns \-1 if ! 51: .I stream ! 52: is not associated with a `popened' command. ! 53: .SH BUGS ! 54: Buffered reading before opening an input filter ! 55: may leave the standard input of that filter mispositioned. ! 56: Similar problems with an output filter may be ! 57: forestalled by careful buffer flushing, for instance, with ! 58: .I fflush, ! 59: see ! 60: .IR fclose (3). ! 61: .LP ! 62: .I Popen ! 63: always calls ! 64: .IR sh , ! 65: never calls ! 66: .IR csh .
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.