![]() |
![]() |
#1 |
∂2ω=0
Sep 2002
República de California
5×2,351 Posts |
![]()
One of my main beta testers, GordP, has convinced me to add signal-catching (e.g. instead of just dying on ctrl-c, complete the current iteration, write savefiles and exit gracefully) to the v18 code upgrades - I have that working, the remaining question is which of the standard set of signals - that is, the catchable ones thereof - the program should listen for. On my Mac, 'man signal' offers the following smorgasbord:
Code:
1 SIGHUP terminate process terminal line hangup 2 SIGINT terminate process interrupt program 3 SIGQUIT create core image quit program 4 SIGILL create core image illegal instruction 5 SIGTRAP create core image trace trap 6 SIGABRT create core image abort program (formerly SIGIOT) 7 SIGEMT create core image emulate instruction executed 8 SIGFPE create core image floating-point exception 9 SIGKILL terminate process kill program 10 SIGBUS create core image bus error 11 SIGSEGV create core image segmentation violation 12 SIGSYS create core image non-existent system call invoked 13 SIGPIPE terminate process write on a pipe with no reader 14 SIGALRM terminate process real-time timer expired 15 SIGTERM terminate process software termination signal 16 SIGURG discard signal urgent condition present on socket 17 SIGSTOP stop process stop (cannot be caught or ignored) 18 SIGTSTP stop process stop signal generated from keyboard 19 SIGCONT discard signal continue after stop 20 SIGCHLD discard signal child status has changed 21 SIGTTIN stop process background read attempted from control terminal 22 SIGTTOU stop process background write attempted to control terminal 23 SIGIO discard signal I/O is possible on a descriptor (see fcntl(2)) 24 SIGXCPU terminate process cpu time limit exceeded (see setrlimit(2)) 25 SIGXFSZ terminate process file size limit exceeded (see setrlimit(2)) 26 SIGVTALRM terminate process virtual time alarm (see setitimer(2)) 27 SIGPROF terminate process profiling timer alarm (see setitimer(2)) 28 SIGWINCH discard signal Window size change 29 SIGINFO discard signal status request from keyboard 30 SIGUSR1 terminate process User defined signal 1 31 SIGUSR2 terminate process User defined signal 2 |
![]() |
![]() |
![]() |
#2 |
"/X\(‘-‘)/X\"
Jan 2013
5·17·37 Posts |
![]()
I would have SIGTERM terminate gracefully. SIGINT should terminate gracefully, but terminate expediently if another SIGINT is received (mfaktc has this behaviour). SIGHUP, SIGKILL and SIGPIPE should terminate expediently.
SIGUSR1 and SIGUSR2 are often used to cause a process to reread configuration files or to gracefully restart. |
![]() |
![]() |
![]() |
#3 |
"Mihai Preda"
Apr 2015
26478 Posts |
![]()
On Linux on Ctrl-C I get SIGINT, and that's what I use to stop gracefully.
|
![]() |
![]() |
![]() |
#4 |
Undefined
"The unspeakable one"
Jun 2006
My evil lair
2×32×373 Posts |
![]()
CTRL-\ sends a SIGQUIT in Linux terminals. Ping uses this to display the current statistics and continues to run.
|
![]() |
![]() |
![]() |
#5 |
∂2ω=0
Sep 2002
República de California
5×2,351 Posts |
![]()
How does one listen for multiple SIGINTs (ctrl-c) in succession? Should one also define some pause-for-X-milliseconds-after-first-SIGINT delay to listen for a second SIGINT rather than performing an immediate savefiles-and-exit?
|
![]() |
![]() |
![]() |
#6 | |
"Oliver"
Mar 2005
Germany
2×557 Posts |
![]()
Hi
Quote:
Oliver |
|
![]() |
![]() |
![]() |
#7 | |
Sep 2003
1010000111012 Posts |
![]() Quote:
The behavior of SIGINT you describe is specific to mfaktc because one CTRL-C means "stop after finishing this factor class", which may take a while, and a second CTRL-C means "no, really stop right now". With programs like mprime and Mlucas, normally writing out an LL or PRP savefile is extremely quick, just a few dozen MB, so the issue doesn't really arise, unless maybe you have a problem with a networked file system. SIGHUP should terminate gracefully. It probably just means that your terminal session ended while the program was running. For instance if you are running a program in an ssh terminal window on your PC, and your PC went to sleep from inactivity. You can avoid that happening by running the program in screen or a similar utility, or by remembering to run the program with nohup (or run disown on the program if it's running in the background). Probably everything should just terminate gracefully, because "graceful" and "expedient" amount to the same thing here. All you have to do is write out a small savefile, and there's no reason not to unless you have some reason to believe your data has become corrupted and should not be saved. Last fiddled with by GP2 on 2019-02-17 at 00:13 |
|
![]() |
![]() |
![]() |
#8 |
"/X\(‘-‘)/X\"
Jan 2013
C4916 Posts |
![]() |
![]() |
![]() |
![]() |
#9 |
"Kieren"
Jul 2011
In My Own Galaxy!
27AE16 Posts |
![]()
That has always been my understanding. What I have not understood is the urgency to quit the program. I think that work on the current class is lost in an immediate shutdown. Unless the per-class time is really inconveniently long, why not let it finish?
|
![]() |
![]() |
![]() |
#10 | |
23·29 Posts |
![]() Quote:
If you run multiple instances of a program, for example gpuowl, there is another way to stop the running instances: Code:
pkill -int openowl will stop all instances of openowl gracefully letting them save checkpoints. |
|
![]() |
![]() |
#11 |
∂2ω=0
Sep 2002
República de California
5·2,351 Posts |
![]()
I've fiddled the code to catch SIGINT, SIGTERM and SIGHUP, print info re. the caught signal and exit gracefully. Users can still use ctrl-\ to force immediate-exit or ctrl-z to suspend the process followed by 'kill [pid]'. There is no multiple-signals-in-a-row handling, I just don't see the need for it in the context of the kind of work Mlucas does.
|
![]() |
![]() |
![]() |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Next GMP release? | Andi47 | GMP-ECM | 6 | 2007-11-26 07:29 |
v24.13 release candidate 1 | Prime95 | Software | 13 | 2005-07-14 23:29 |
V24.12 release candidate 3 | Prime95 | Software | 45 | 2005-07-02 19:13 |
V24.12 Release 1 Crashing on P4 M | njcroquet1 | Software | 8 | 2005-06-24 14:40 |
Release of Exponents | nitro | Lone Mersenne Hunters | 3 | 2004-01-02 06:41 |