Re: [Rd] Sighandlers

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Sun, 18 Nov 2012 14:17:10 +0000

R has its own signal handlers, including for SIGINT.

What is your 'extension'? If it is a program embedding R, the order of setting signal handlers will matter, and in any case R's handler if ever called it will reset the handler to itself.

If it is a package, it should not be messing with the process into which it is loaded.

On 17/11/2012 15:56, Ulrich Staudinger wrote:
> Hello everyone,
>
> I am searching and searching and can't find an answer.

Did you search the source code?

>
> I try to register a sighandler in my extension's C code. But my
> sighandler is never called. Is there anything preventing extensions to
> receive signals?
>
> I register like this:
>
> [.. some code that works ..]
> // register the sigint listeners.
> if (signal(SIGTERM, killReceiver) == SIG_ERR) {
> printf("2 An error occurred while setting a signal
> handler.%s\n", stderr);
> }
> if (signal(SIGHUP, killReceiver) == SIG_ERR) {
> printf("3 An error occurred while setting a signal
> handler.%s\n", stderr);
> }
> if (signal(SIGINT, killReceiver) == SIG_ERR) {
> printf("4 An error occurred while setting a signal
> handler.%s\n", stderr);
> }
> [.. even more code that works ..]
>
>
> handler code:
>
> static void killReceiver(int signum){
> printf("Cleaning up\n");
> }
>
>
> When I exit R, my signal handler is not being called. Am I listening
> to the right signals? Do I have some misunderstanding on my side?
>
> Funny side story, if I manually raise(SIGINT), my handlers gets called.
>
>
> Thanks for some light on this,
>
> Ulrich
>
>
>
>
>
> --
> Ulrich Staudinger
>
> P: +41 79 702 05 95
> E: ustaudinger_at_activequant.com
>
> http://www.activequant.com
> Connect online: https://www.xing.com/profile/Ulrich_Staudinger
>
> ______________________________________________
> R-devel_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
Brian D. Ripley,                  ripley_at_stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Sun 18 Nov 2012 - 14:19:43 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 26 Nov 2012 - 14:50:53 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive