17 lines
488 B
C
17 lines
488 B
C
#include <stdio.h> // p r i n t f
|
|
#include <stdlib.h> // e x i t ( . . ) , EXIT_SUCCESS
|
|
#include <unistd.h> // f o r k ( ) , getpid ( )
|
|
|
|
|
|
int main ( int argc , char * argv []) {
|
|
pid_t fvalue = fork ();
|
|
if ( fvalue != 0) {
|
|
// Parent process
|
|
printf("[%ld] I am your father , %ld!\n " , getpid () , fvalue );
|
|
} else {
|
|
// Child process
|
|
printf("[%ld] Nooooooooooooooo ! (%ld)\n " , getpid () , fvalue );
|
|
}
|
|
exit ( EXIT_SUCCESS );
|
|
}
|