ppooppeenn() -- STDIO Function (libc)

Open a pipe
#iinncclluuddee <ssttddiioo.hh>
FFIILLEE *ppooppeenn(_c_o_m_m_a_n_d, _h_o_w)
cchhaarr *_c_o_m_m_a_n_d, *_h_o_w;

ppooppeenn() opens  a pipe.  It resembles the function  ffooppeenn(), except that the
opened object is a command line to the shell sshh rather than a file.

The caller can read the standard  output of _c_o_m_m_a_n_d when _h_o_w is rr, or write
to the standard input of _c_o_m_m_a_n_d  when _h_o_w is ww.  ppooppeenn() returns a pointer
to a FFIILLEE structure that may be read or written.

_E_x_a_m_p_l_e
This example is equivalent to the command

ls -l | mail me
where mmee is your login identifier.

#include <stdio.h>
main()
{
    FILE *ifp, *ofp;
    int c;

    if ((NULL == (ofp = popen("lmail me", "w"))) ||
        (NULL == (ifp = popen("ls -l",     "r")))) {
            fprintf(stderr, "cannot popen\n");
        exit(1);
    }

    while (EOF != (c = fgetc(ifp)))
        fputc(c, ofp);

    pclose(ifp);
    pclose(ofp);
}

_F_i_l_e_s
<ssttddiioo.hh>

_S_e_e _A_l_s_o
ffcclloossee(), ffooppeenn(), lliibbcc, ppcclloossee(), ppiippee(), sshh, ssyysstteemm(), wwaaiitt()

_D_i_a_g_n_o_s_t_i_c_s
ppooppeenn() returns NULL if the link to _c_o_m_m_a_n_d could not be established.
