Detect Close of a background process

This is a discussion on Detect Close of a background process within the C Programming forums, part of the General Programming Boards category; Right now I have a program that executes another program and lets it run in the background. I want to ...

  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    23

    Detect Close of a background process

    Right now I have a program that executes another program and lets it run in the background. I want to know when the background process quits. I also want to know which background process quits, I can have multiple background processes running at the same time. All my background processes are stored in an array.

    I am trying to use the SIGCHLD, but I can't find a way to see which process actually sent the signal. I just get a default signal for whatever process closes.

    Any ideas on how I can use SIGCHLD or anything else?

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,333
    Consider wait4() with a pid of -1 and a WNOHANG option
    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. fork, execv, spawn, or something else?
    By DavidP in forum C++ Programming
    Replies: 8
    Last Post: 01-26-2009, 03:25 PM
  2. Check number of times a process is running
    By linuxwolf in forum Windows Programming
    Replies: 6
    Last Post: 10-17-2008, 11:08 AM
  3. Replies: 3
    Last Post: 10-15-2008, 09:24 AM
  4. Replies: 12
    Last Post: 05-17-2003, 05:58 AM
  5. Ghost in the CD Drive
    By Natase in forum A Brief History of Cprogramming.com
    Replies: 17
    Last Post: 10-12-2001, 05:38 PM

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