I need to set two alarm(). The first one to kill one process, the second one to kill all the processes I got. Obviously the first alarm is smaller than the second one. How can I handle the two SIGALRM (and then the SIGTERM) in order to make these things? I mean, is possible to handle differently the same signal from two different alarm()?
Asked
Active
Viewed 103 times
0
-
2Are you saying that the first time you get a SIGALARM you want to perform one actin, and the second time you get a SIGALARM you do something else? If so, use a global variable to track it. – dbush Mar 17 '18 at 22:22
-
2When you use `alarm()`, the OS only keeps track of a single alarm for you. If you need two alarms, for M and N seconds from now, you'll have to arrange to set ehe second one (for N-M seconds) as or after the first one fires. You might want to set up a genersl piece of alarm management code for this. – Steve Summit Mar 17 '18 at 22:29
-
1Or you might be able to use `timer_create()`, which does let you create multile timers all running at once. – Steve Summit Mar 17 '18 at 22:35
-
Thanks for the answers. Is possible, with timer_create to set a timer which start again at the end after it performed an action, and a second (longer) timer which perform another action at the end? Hope I explained well what I want to do – palnic Mar 17 '18 at 22:49
-
1@palnic I think so. To be sure I would have to check the documentation of `timer_create` -- which you can do, too! Just do a web search. – Steve Summit Mar 17 '18 at 22:53