-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path13b.c
More file actions
41 lines (34 loc) · 1.18 KB
/
13b.c
File metadata and controls
41 lines (34 loc) · 1.18 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
37
38
39
40
41
/*
============================================================================
Name : 13b
Author : Piyush Singh
Description : Write two programs: first program is waiting to catch SIGSTOP signal, the second program
will send the signal (using kill system call). Find out whether the first program is able to catch
the signal or not.
Date: 19th Sep, 2025.
============================================================================
*/
// Program 2: Sender — sends SIGSTOP to another process
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
int main()
{
pid_t target_pid;
// Ask user for the PID of the receiver program
printf("🎯 Enter the PID of the receiver process: ");
scanf("%d", &target_pid);
// Send SIGSTOP to the target process
if (kill(target_pid, SIGSTOP) == 0)
printf("✅ Sent SIGSTOP to process %d. It should now be paused.\n", target_pid);
else
perror("❌ Failed to send SIGSTOP");
return 0;
}
/*
Output:
╰─ ./13b ─╯
🎯 Enter the PID of the receiver process: 21084
✅ Sent SIGSTOP to process 21084. It should now be paused.
*/