[R] a way to interrupt a stuck R session on OSX

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Jan 14 07:36:05 CET 2008


On Sun, 13 Jan 2008, Josh Tolley wrote:

> On Jan 13, 2008 8:02 PM, Day, Roger S. <day at upci.pitt.edu> wrote:
>> Discovered by accident:
>>
>> If your R session has become unresponsive to escape presses etcetera,
>> you can try this.
>> Open a terminal window, run the command
>>
>> ps -ax | grep R.app
>>
>> Note the process ID number in the first column.  Say it's 1234.
>> Then run
>>
>> kill -4 1234
>>
>> The key is that the signal you are sending to R.app is "4".
>>
>> The Console will now ask you how you want to exit.
>> This at a minimum gives you a chance to save any window content,
>> since it's a nicely threaded application.
>> Once (of 2 times) I could also cancel out of the dialog and resume the
>> session.
>
> What signal is signal 4 on your OS (or more specifically, what signal
> is it that R responds to in this manner)? If I understand correctly,
> different OS's supporting kill(1) vary in the interpretation of
> numerically specified signals, though I can only report this as
> hearsay, and not provide specific examples. Nevertheless, folks in my
> little circle tend to use kill -SIGTERM, kill -SIGQUIT, etc. rather
> than numeric signal specifiers just in case kill(1) behaves
> differently than they expect.

Agreed (but some signal numbers are pretty much standard, e.g. 1,2,3). 
Signal 4 is SIGILL on MacOS X, and I believe the R signal handler (not due 
to R.app's authors) is responsible: the behaviour quoted holds for any 
Unix-alike R.

If you want to save the work and terminate on any Unix-alike, send SIGUSR1 
or SIGUSR2.  See ?Signals.  SIGUSR1 can be 30, 10 or 16 even on Linux, 
depending on the architecture.

-- 
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




More information about the R-help mailing list