-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path012.c
More file actions
36 lines (31 loc) · 1.02 KB
/
012.c
File metadata and controls
36 lines (31 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
..........................................................................................................................................
Name : 012.c
Author : SHRUTI VERMA
Description : Write a program to create an orphan process. Use kill system call to send SIGKILL signal to
the parent process from the child process
Date : 20 Sep 2025
..........................................................................................................................................
*/
#include<unistd.h>
#include<stdio.h>
#include<stdlib.h>
#include<signal.h>
int main() {
if(!fork()) {
sleep(5);
printf("child process : %d\n", getpid());
kill(getppid(), SIGKILL);
printf("killed the parent\n");
} else {
printf("parent process : %d\n", getpid());
sleep(15);
}
return 0;
}
/*----------------------------------OUTPUT----------------------------------------------------------------
parent process : 13078
child process : 13079
killed the parent
Killed
*/