24 lines
545 B
C
24 lines
545 B
C
#include <stdio.h>
|
|
#include <sys/types.h>
|
|
#include <unistd.h>
|
|
|
|
int main(){
|
|
|
|
pid_t pid;
|
|
pid = fork();
|
|
|
|
if (pid == 0) {
|
|
printf("The current process %d is a child process.\n",getpid());
|
|
printf("PID: %d \nPPID: %d \n", getpid(), getppid());
|
|
} else if (pid > 0) {
|
|
printf("The current process %d is a parent process.\n", getpid());
|
|
printf("PID: %d \nPPID: %d \n", getpid(), getppid());
|
|
} else {
|
|
printf("The system encountered an error. \n");
|
|
printf("Kindly visit https://aadit.cc for more queries. \n");
|
|
return -1;
|
|
}
|
|
|
|
return 0;
|
|
|
|
} |