-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsignaux.py
More file actions
49 lines (41 loc) · 1.77 KB
/
signaux.py
File metadata and controls
49 lines (41 loc) · 1.77 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
42
43
44
45
46
47
48
49
# **************************************************************************** #
# #
# ::: :::::::: #
# signaux.py :+: :+: :+: #
# +:+ +:+ +:+ #
# By: skhatir <marvin@42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2016/06/30 10:05:29 by skhatir #+# #+# #
# Updated: 2016/06/30 10:05:30 by skhatir ### ########.fr #
# #
# **************************************************************************** #
import signal
import task_lib
class siglib:
def __init__(self):
self.dico = signal.__dict__
signal.signal(signal.SIGALRM, self.sig_alarm)
signal.signal(signal.SIGINT, self.sig_int)
signal.signal(signal.SIGCONT, self.sig_cont)
signal.signal(signal.SIGQUIT, self.sig_quit)
signal.alarm(1)
def get_signum(self, name):
if (name):
for k, v in self.dico.iteritems():
if k.startswith('SIG') and not k.startswith('SIG_') and k.endswith(name):
return (v)
return (0)
def sig_quit(self ,signal, frame):
task_lib.log.info('SIGQUIT has been called')
pass
def sig_cont(self ,signal, frame):
task_lib.log.info('SIGCONT has been called')
print ("A AJOUTER: la simulation control+D") ####
def sig_int(self ,signal, frame):
task_lib.log.info('SIGINT has been called')
pass
def sig_alarm(self, signum, frame):
task = task_lib.task
if (task):
task.check_status()
signal.alarm(1)