33 lines
566 B
C
33 lines
566 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>
|
|
|
|
void child_task() {
|
|
execl("/usr/bin/cal", "cal", "2021", NULL);
|
|
}
|
|
|
|
int main() {
|
|
pid_t pid;
|
|
int status;
|
|
|
|
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);
|
|
}
|
|
|
|
wait(&status);
|
|
return 0;
|
|
}
|