previous | start | next

Example (fork)

    1   
    2   #include <stdio.h>
    3   #include <stdlib.h>
    4   #include <unistd.h>
    5   #include <sys/wait.h>
    6   #include <signal.h>
    7   
    8   int main(int argc, char* argv[])
    9   {
   10     pid_t n;
   11     int i;
   12   
   13     n = fork();
   14     printf("fork returned %d, my pid is %d\n", n, getpid());
   15     printf("pid %d: Hello\n", getpid());
   16   
   17     return 0;
   18   }

What is the output?

How many processes?

Which process finishes first?



previous | start | next