12
|
1 |
/*
|
|
2 |
stdin mix - a mixer/multiplexer for stdin to processes
|
|
3 |
Copyright (C) 2007 LluĂs Batlle i Rossell
|
|
4 |
|
|
5 |
Please find the license in the provided COPYING file.
|
|
6 |
*/
|
7
|
7 |
#include <signal.h>
|
|
8 |
|
|
9 |
#include "main.h"
|
|
10 |
|
|
11 |
static int child;
|
|
12 |
|
|
13 |
static void forward_signals_to_child_handler(int val)
|
|
14 |
{
|
|
15 |
kill(child, val);
|
|
16 |
}
|
|
17 |
|
|
18 |
int install_signal_forwarders(int _child)
|
|
19 |
{
|
|
20 |
struct sigaction act;
|
|
21 |
|
|
22 |
child = _child;
|
|
23 |
|
|
24 |
act.sa_handler = forward_signals_to_child_handler;
|
|
25 |
/* Reset the mask */
|
|
26 |
memset(&act.sa_mask,0,sizeof(act.sa_mask));
|
|
27 |
act.sa_flags = 0;
|
|
28 |
|
|
29 |
sigaction(SIGTERM, &act, 0);
|
|
30 |
sigaction(SIGINT, &act, 0);
|
|
31 |
}
|