diff --git a/OS/C/Week5/q1.c b/OS/C/Week5/q1.c new file mode 100644 index 0000000..c3fc4cd --- /dev/null +++ b/OS/C/Week5/q1.c @@ -0,0 +1,24 @@ +#include +#include +#include + +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; + +} \ No newline at end of file