-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsignal.c
More file actions
53 lines (48 loc) · 977 Bytes
/
Copy pathsignal.c
File metadata and controls
53 lines (48 loc) · 977 Bytes
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
42
43
44
45
46
47
48
49
50
51
52
53
/*
* VnetCard: Signal
*
* (C) 2019.05.14 <buddy.zhang@aliyun.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <fcntl.h>
#include <sys/types.h>
#include <base.h>
/* Handle signal from system */
static void do_signal(int sig)
{
struct vc_node *vc;
switch (sig) {
case SIGSTOP:
/* CTRL Z */
case SIGINT:
/* CTRL C */
case SIGQUIT:
/* CTRL \ */
case SIGTERM:
/* Termnal */
case SIGKILL:
/* Kill -9 */
/* Relase */
vc = vc_root();
vc->flags = 0;
break;
default:
fprintf(stderr, "Undefined signal.\n");
}
}
/* Initialize all signal */
void signal_init(void)
{
signal(SIGSTOP, do_signal);
signal(SIGINT, do_signal);
signal(SIGQUIT, do_signal);
signal(SIGKILL, do_signal);
signal(SIGTERM, do_signal);
}