Interruptible calculations

James Youngman jay at gnu.org
Tue Apr 14 22:46:17 CEST 2009


On Tue, Apr 14, 2009 at 6:11 PM, Jafet <jafet.vixle at gmail.com> wrote:
> I am writing a simple calculator that uses GMP.
>
> I would like it to be human-friendly and especially allow a keyboard
> interrupt to quit a calculation and return to the prompt. However, if a
> GMP function is executing at the moment I would want to force it to stop
> and quit cleanly when the program gets a SIGINT.

If all you need to do is quit cleanly, just don't catch SIGINT.    A
fatal exit is the default for SIGINT anyway.

> Is there some best way to do this, or should I not bother?

"not bothering" is the best way.

If you want to handle the signal somehow, and especially if you want
your signal handler to return, then things get a little more complex.

James.


More information about the gmp-discuss mailing list