*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->Tru64 Unix man pages -> popen (3)              
Title
Content
Arch
Section
 

popen(3)

Contents


NAME    [Toc]    [Back]

       popen - Initiates a pipe to a process

SYNOPSIS    [Toc]    [Back]

       #include <stdio.h>

       FILE *popen(
               const char *command,
               const char *type );

LIBRARY    [Toc]    [Back]

       Standard C Library (libc)

STANDARDS    [Toc]    [Back]

       Interfaces  documented  on  this reference page conform to
       industry standards as follows:

       popen():  XPG4, XPG4-UNIX

       Refer to the standards(5) reference page for more information
 about industry standards and associated tags.

PARAMETERS    [Toc]    [Back]

       Points to a null-terminated string containing a shell command
 line.  Points to a null-terminated string  containing
       an I/O mode.

DESCRIPTION    [Toc]    [Back]

       The  popen()  function  creates a pipe between the calling
       program and a shell command to be executed. It  returns  a
       pointer to a FILE structure for the stream.

       If  the type parameter is the value r, the calling program
       can read from the standard output of the command by  reading
  from  the returned file stream. If the type parameter
       is the value w, the calling program can write to the standard
  input of the command by writing to the returned file
       stream.

       Because open files are shared, a type  r  command  can  be
       used  as an input filter and a type w command as an output
       filter.

NOTES    [Toc]    [Back]

       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  by  either  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 calling the pclose() function.

                                Caution

       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    [Toc]    [Back]

       Upon successful completion, the popen() function returns a
       pointer to the FILE structure for the  opened  stream.  In
       case of error because files or processes could not be created,
 the popen() function returns a null pointer.

SEE ALSO    [Toc]    [Back]

      
      
       Functions:   exec(2),   fork(2),   fclose(3),    fopen(3),
       pclose(3), pipe(2), setbuf(3)

       Standards: standards(5)



                                                         popen(3)
[ Back ]
 Similar pages
Name OS Title
popen IRIX initiate pipe to/from a process
pclose Tru64 Closes a pipe to a process
tee IRIX pipe fitting
tee HP-UX pipe fitting
tee OpenBSD pipe fitting
pipe Linux create pipe
tee FreeBSD pipe fitting
lio_listio Tru64 Initiates a list of asynchronous I/O requests
fifo Linux first-in first-out special file, named pipe
udbp FreeBSD USB Double Bulk Pipe driver
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service