Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Simple Linux Processes Program

  1. Nov 18, 2008 #1
    I try to make a program which gets the number of desired childs from user, then creates them sequentially and destroys them in reverse order.
    I just don't understand why it doesn't work correctly :(

    Code (Text):

    #include <stdio.h>
    #include <unistd.h>
    #include <sys/wait.h>

    int main(int argc, char** argv) {
            int pid, status,n_sons,current_son=0;
            printf("Enter number of sons:");

            do {
                    if(pid !=0 ) {
                            printf("Created Son, with PID:%d and PPID:%d\n",pid,getppid());
                            printf("Son with PID:%d, terminated with status:%d\n",pid,status);
                    else {
            }while(current_son < n_sons);

            return 0;

  2. jcsd
  3. Nov 18, 2008 #2
    found the problem
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook