Thread: Forking child processes form parent to exec commands

  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    178

    Forking child processes form parent to exec commands

    I ask this question again in hope it is not responded to by someone with less intelligence than a rodent.

    I understand process execution, forking, and termination. Right now my program is able to fork one child, exec ls -lai, then dies. I have been trying to understand why this happens.

    I have used waitpid and wait() in general but I think I am lacking a clear point of understanding with regard to processes in UNIX. I read the FAQ but it entirely all but clear on process execution under UNIX.

    Any help is appreciated but if you would like to share how I should not know this because you feel I am in danger of learning how to execute denial-of-service attacks or want to be a general .............., leave now please.

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    but if you would like to share how I should not know this because you feel I am in danger of learning how to execute denial-of-service attacks or want to be a general .............., leave now please.
    Bear in mind that the most helpful people on this board have been here for years, and have thousands and thousands of posts. They have seen a lot of people register who know very little about programming, and immediately start asking how to write malicious software. They have good reason to chase away script kiddies. I'm not suggesting that you are coding a DoS attack, but you'll find you recieve much more help if you focus on changing your own attitude rather than someone else, right or wrong. If you're writing code that might be confused with something malicious, be open about it - tell us more about what you're doing and maybe even post your code. Everyone who's here is here because they like helping people who are here to learn.

    Right now my program is able to fork one child, exec ls -lai, then dies. I have been trying to understand why this happens.

    I have used waitpid and wait()...
    I'm a little confused about which process is doing what - you'll probably need to post your code so we can see what's going on. It sounds like a loop of some sort might be messed up?

  3. #3
    Registered User
    Join Date
    May 2010
    Posts
    178
    Don't concern yourself, the problem was solved by me already.

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by Imanuel
    Don't concern yourself, the problem was solved by me already.
    Good to hear that.

    *thread closed*
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 6
    Last Post: 05-01-2011, 11:06 AM
  2. Why isn't the execlp() function doing anything?
    By jsrig88 in forum C Programming
    Replies: 5
    Last Post: 10-12-2009, 10:09 AM
  3. Replies: 3
    Last Post: 10-15-2008, 09:24 AM
  4. process programming
    By St0rM-MaN in forum Linux Programming
    Replies: 2
    Last Post: 09-15-2007, 07:53 AM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM