blob: 7b32d31c17d3152e8c68ae9dce78f679f2e5a508 (
plain)
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
|
#include "signal_handler.h"
#include <errno.h>
namespace ov4
{
/*
* sigtstp_handler - The kernel sends a SIGTSTP to the shell whenever
* the user types ctrl-z at the keyboard. Catch it and suspend the
* foreground job by sending it a SIGTSTP.
*/
void sigtstp_handler([[maybe_unused]] int sig)
{
int errno_backup = errno;
sigset_t prev;
block_handler(&prev);
int pid = fgpid();
if (pid != 0)
{
kill(-pid, SIGTSTP);
}
sigprocmask(SIG_SETMASK, &prev, nullptr);
errno = errno_backup;
return;
}
}
|