This repository has been archived on 2026-03-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
TP-TR/chap0/parent.c
Super_JK bd84de1a32 :,)
2022-03-29 17:17:15 +02:00

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 );
}