29 lines
632 B
C
29 lines
632 B
C
//
|
|
// Written for Computer Networks and Systems lab classes
|
|
// AUTHOR : Sergiusz Warga
|
|
|
|
#include <stdio.h>
|
|
#include <sys/types.h>
|
|
#include <unistd.h>
|
|
#include <stdlib.h>
|
|
#include "child_functions.h"
|
|
|
|
int main() {
|
|
pid_t pid;
|
|
|
|
pid = fork();
|
|
|
|
if (pid == -1) { // If something went wrong.
|
|
perror("Fork: ");
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
|
|
if (pid == 0) { // If this is a child process.
|
|
child_task();
|
|
exit(EXIT_SUCCESS);
|
|
}
|
|
|
|
printf("I am a parent.\n");
|
|
sleep(1); // This may be required as the parent process won't wait for the child process to finish its execution.
|
|
return 0;
|
|
} |