Thread: writing to a child

  1. #1
    Registered User
    Join Date
    Oct 2001

    writing to a child

    I'm writing a program with different moduals and functions. Basically the program opens a child
    using a fork than execl and pipes are created to
    communicate between parent and child. What I can't seem to do is write from the parent to the child after I have left the function that opens the child. In on .h file I have:

    #define fdwr (rdfile[1]) //simple short cuts
    #define fdrd (wrfile[0]) // to handles

    extern int rdfile[2];
    extern int wrfile[2];
    in the .cpp file used to open the child I have defined:

    int rdfile[2];
    int wrfile[2];

    the function looks like:
    int OpenTelnet(char *pszAddress, char *pszPort)
    if (tnproc) return 0;
    tnproc = fork();
    if (!tnproc)
    dup2(rdfile[0], fileno(stdin));
    dup2(wrfile[1], fileno(stdout));
    execl(TELNET, TELNET, pszAddress, pszPort, NULL);

    As I say as long as I am in this function I can write to the child using
    write(fdwr, szBuffer, strlen(szBuffer));
    The problem is writing later in the program. Can
    you direct me.

    Thanks inadvance.

  2. #2
    Registered User
    Join Date
    Oct 2001
    Problem fixed the code worked.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. create a child process that creates a child process
    By cus in forum Linux Programming
    Replies: 9
    Last Post: 01-13-2009, 02:14 PM
  2. Replies: 3
    Last Post: 10-15-2008, 09:24 AM
  3. process programming
    By St0rM-MaN in forum Linux Programming
    Replies: 2
    Last Post: 09-15-2007, 07:53 AM
  4. Folding@Home Cboard team?
    By jverkoey in forum A Brief History of
    Replies: 398
    Last Post: 10-11-2005, 08:44 AM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM