fork.c
changeset 138 dff18d1ac2af
parent 77 49e0babccb23
child 139 cb1d3f4cf18e
equal deleted inserted replaced
137:d8a0984b72fc 138:dff18d1ac2af
    16 
    16 
    17     pid = fork ();
    17     pid = fork ();
    18     switch (pid) {
    18     switch (pid) {
    19     case 0:
    19     case 0:
    20         printf ("Starting new Process\n");
    20         printf ("Starting new Process\n");
    21         execve (cmd, argv, argp);
    21         return execve (cmd, argv, argp);
    22     case -1:
    22     case -1:
    23         perror ("FORK");
    23         perror ("FORK");
    24         return errno;
    24         return errno;
    25     default:
    25     default:
    26         printf ("Pid started as %d\n", pid);
    26         printf ("Pid started as %d\n", pid);
    27         wait (&pid);
    27         wait (&pid);
    28         printf ("Exit-Status = %d\n", pid);
    28         printf ("Exit-Status = %d\n", pid);
       
    29 
    29         return pid;
    30         return pid;
    30     }
    31     }
       
    32 
       
    33     // should never happen
       
    34     return -1;
    31 }
    35 }
    32 
    36 
    33 int main (int argc, char **argv)
    37 int main (int argc, char **argv)
    34 {
    38 {
    35     char *args[] = {
    39     char *args[] = {