manage processes

This is a discussion on manage processes within the C Programming forums, part of the General Programming Boards category; (Using C on ubuntu) In my program I need to fork a process and execute a .bin in the child ...

  1. #1
    frs
    frs is offline
    Registered User
    Join Date
    Jun 2010
    Posts
    29

    manage processes

    (Using C on ubuntu)

    In my program I need to fork a process and execute a .bin in the child process. Then I want to create a pipe that "connects" the stdout of the child to the stdout of the parent. I know basically how to do this using write() and read() in the pipes.
    The problem is that the parent should wait until the child sends a specific message (a string), or until a timeout occurs. In the first case both processes should run in "parallel" ( I don't know if its the correct term..), in the second case the child must abort and the parent go on. And I don't have a clue how to accomplish any of this things. Any suggestions ?

    I made a very basic skeleton, comments?


    Code:
     int status;
        int fd[2]; /* pipe */
    
        if( pipe(fd) !=0 )
        {
          perror("Failed to create pipe");
          exit(EXIT_FAILURE);
        }
    
        pid_t pid=fork();
    
        if( pid<0)
        {
          perror("Failed to fork");
          exit(EXIT_FAILURE);
        }
    
        else if(pid == 0) /* child */
        {
          if(execl("/usr/bin/sixad","sixad","-s",NULL)==-1);
          perror("Child unabled to start sixad");
    
          exit(EXIT_FAILURE);
        }
    sorry for the cross posting in the linux forum. I ask the moderators to eliminate the other post please.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,751
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 34
    Last Post: 05-27-2009, 01:26 PM
  2. Processes not dying
    By Elkvis in forum Linux Programming
    Replies: 12
    Last Post: 04-23-2008, 09:59 AM
  3. Problems defining classes
    By esmeco in forum C++ Programming
    Replies: 47
    Last Post: 10-24-2007, 02:13 PM
  4. binary tree of processes
    By gregulator in forum C Programming
    Replies: 1
    Last Post: 02-28-2005, 12:59 AM
  5. Computer Processes.... Which can be stopped?
    By Sevrin in forum Tech Board
    Replies: 3
    Last Post: 06-08-2003, 09:13 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21