From ripley at stats.ox.ac.uk  Wed Aug 14 18:38:57 2013
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Wed, 14 Aug 2013 17:38:57 +0100
Subject: [Rd] 2 questions about signal & broken connection in R
In-Reply-To: <OF26FEB442.E4CCE09D-ON48257BC7.003847CF-48257BC7.0039D50D@cn.ibm.com>
References: <OF26FEB442.E4CCE09D-ON48257BC7.003847CF-48257BC7.0039D50D@cn.ibm.com>
Message-ID: <520BB2A1.10308@stats.ox.ac.uk>

You seem to be assuming that Ctrl-C is the way to interrupt an R session 
and that it sends a signal.  Neither are true, in general, nor is there 
a general way to turn off interruptibility from the R console.

You have not followed the posting guide and it may be that you are only 
interested in some particular R setup -- which you did not tell us about.

If you want to run code so that it is not interruptible from a console, 
do not run it from a console ....

On 14/08/2013 11:30, Rong lI Li wrote:
>
>
> Hi, all,
>
> I have 2 questions about signal handling in R. Would you pls help give me
> some suggestions? Many thanks!
>
> [How to block the signal in one R function]:
> If one R function hopes to be running without interrupting, how can we
> avoid this?
> To be more specific, for one R function "func1", it will do a loop to send
> messages to another R process, and receive responses from peers. How can we
> avoid users interrupt this function by pressing "Ctrl+C", so that it can
> finish normally, without messing up the message protocol? Are there any way
> to block signal handling within the function?
>
> [why writing to one broken connection for the 3rd time will hang, instead
> of getting exceptions]:
> Such as, there is one broken socket connection (in blocking mode), which is
> closed by peer by calling "close(conn)".
> The 1st write will return. The 2nd write will get an exception. The 3rd
> write will hang there forever.
> How can users always get an exception or other error messages when writing
> to a broken connection, instead of possibly hanging there?
>
>> writeBin(as.integer(1), con, endian="big");
>> writeBin(as.integer(1), con, endian="big");
> Error in writeBin(as.integer(1), con, endian = "big") :
>    ignoring SIGPIPE signal
>> writeBin(as.integer(1), con, endian="big");  ----- hanging
>
>
> =====================
>
> Rong "Jessica", Li
> Platform Symphony TET, CSTL, IBM Systems &Technology Group, Development
> Tel:86-10-82451010  Email:ronglli at cn.ibm.com
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> 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



[Rd] 2 questions about signal & broken connection in R
Prof Brian Ripley