how to check if a child process is done?

This is a discussion on how to check if a child process is done? within the Linux Programming forums, part of the Platform Specific Boards category; I'm working on a simple shell for an os class that needs to be capable of running processes in the ...

  1. #1
    GA ichijoji's Avatar
    Join Date
    Nov 2002
    Posts
    179

    how to check if a child process is done?

    I'm working on a simple shell for an os class that needs to be capable of running processes in the foreground and background. I have this working fine, but I need to be able to check if a process is done (using its pid) so I can keep a list of running background processes. Is there any simple way to do this?
    Illusion and reality become impartiality and confidence.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,485
    Use waitpid() with the NOHANG option if you want to go round a list of children looking to see which ones have exited.
    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. [c++] check if a process is already running
    By liquid_ice in forum Linux Programming
    Replies: 0
    Last Post: 05-12-2009, 03:30 AM
  2. create a child process that creates a child process
    By cus in forum Linux Programming
    Replies: 9
    Last Post: 01-13-2009, 01:14 PM
  3. Listen to stdio of child process in parent
    By nitinmhetre in forum Linux Programming
    Replies: 2
    Last Post: 12-20-2006, 08:16 AM
  4. Child process I/O
    By madmardigan53 in forum Windows Programming
    Replies: 6
    Last Post: 08-23-2004, 10:40 PM
  5. core dump by child process
    By anoopks in forum Linux Programming
    Replies: 1
    Last Post: 08-09-2003, 07:35 AM

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