Need some quick C++ help !

Discussion in 'OT Technology' started by TheDarkHorizon, Mar 25, 2003.

  1. TheDarkHorizon

    TheDarkHorizon \xC0\xFF\xEE

    Joined:
    Sep 26, 2002
    Messages:
    2,396
    Likes Received:
    0
    Location:
    San Francisco, CA
    I'm programming in a win32 enviornment using Visual C++. My problem is that I have a program which uses the system() call on itself (argv[0]) to spawn the same program on error, but the other first program does not reach return -1; which causes it to stay open with the second one open at the same time. Then the second one opens a third one, leaving the first and second. So it leaves an infinite train of processes open. Is there any way around this?
     
  2. SLED

    SLED build an idiot proof device and someone else will

    Joined:
    Sep 20, 2001
    Messages:
    28,118
    Likes Received:
    0
    Location:
    AZ, like a bauce!
    well, you have a case of endless recurrsion. What are you trying to do that you need it to span another instance on error? If you have no way to return an error code, then you might be hosed.
     
  3. skinjob

    skinjob Active Member

    Joined:
    Jan 6, 2001
    Messages:
    2,337
    Likes Received:
    0
    Location:
    Aztlán
    system() is not the right choice. The reason your first program doesn't exit is that it's waiting for system() to return, i.e. it's waiting for the second process to exit. I think you probably want to use CreateProcess().
     

Share This Page