Interactiveness

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Interactiveness

Bjarni Juliusson
Hi list!

I'm developing R integration for a project called Bioclipse at Uppsala
University. The current implementation works by simply forking an R and
sending it text (with some substitutions on it) down a pipe, getting the
printed output back up another pipe. This of course works fine, except
it runs into one problem: R finds a pipe on its stdin and decides to be
"non-interactive", which means that as soon as the user makes a typo and
causes an error, R exits.

I checked the source, and it's a couple of isatty()'s in the two files
named system.c that are doing it. They are of course intended to be a
feature, but in this case it causes us trouble. Would it be possible to
get a command line switch to control this behaviour? I'm not sure pseudo
terminals can be used portably, or can they? Are those few lines with
the isatty's, which set R_Interactive to FALSE, the only places that
need to be patched (besides adding the switch somewhere)? Should I send
in a complete patch or is a request for functionality sufficient?

Lots of questions there, grateful for any answers! :-)


Bjarni
--

                        INFORMATION WANTS TO BE FREE

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Interactiveness

Prof Brian Ripley
On Tue, 11 Dec 2007, Bjarni Juliusson wrote:

> Hi list!
>
> I'm developing R integration for a project called Bioclipse at Uppsala
> University. The current implementation works by simply forking an R and
> sending it text (with some substitutions on it) down a pipe, getting the
> printed output back up another pipe. This of course works fine, except
> it runs into one problem: R finds a pipe on its stdin and decides to be
> "non-interactive", which means that as soon as the user makes a typo and
> causes an error, R exits.

Actually, not so.  The default error handler for non-interactive use is to
do that, but you can change it.

> I checked the source, and it's a couple of isatty()'s in the two files
> named system.c that are doing it. They are of course intended to be a
> feature, but in this case it causes us trouble. Would it be possible to
> get a command line switch to control this behaviour? I'm not sure pseudo
> terminals can be used portably, or can they?

They can, and are e.g. by ESS (except on Windows, where there is already a
switch).  I think you need to look a bit more carefully at what other
projects do.

--
Brian D. Ripley,                  [hidden email]
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

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Interactiveness

Bjarni Juliusson
Prof Brian Ripley wrote:

> On Tue, 11 Dec 2007, Bjarni Juliusson wrote:
>> I'm developing R integration for a project called Bioclipse at Uppsala
>> University. The current implementation works by simply forking an R and
>> sending it text (with some substitutions on it) down a pipe, getting the
>> printed output back up another pipe. This of course works fine, except
>> it runs into one problem: R finds a pipe on its stdin and decides to be
>> "non-interactive", which means that as soon as the user makes a typo and
>> causes an error, R exits.
>
> Actually, not so.  The default error handler for non-interactive use is
> to do that, but you can change it.

Could you perhaps just point me in the right direction here? I really
have no idea how to do this.

Also, what exactly does non-interactive mode imply, besides this default
error handling behaviour?

>> I checked the source, and it's a couple of isatty()'s in the two files
>> named system.c that are doing it. They are of course intended to be a
>> feature, but in this case it causes us trouble. Would it be possible to
>> get a command line switch to control this behaviour? I'm not sure pseudo
>> terminals can be used portably, or can they?
>
> They can, and are e.g. by ESS (except on Windows, where there is already
> a switch).  I think you need to look a bit more carefully at what other
> projects do.

It needs to be portable to Windows. I'll look into this possibility next.

Didn't mean to ask before I had done my homework. Thanks for your help!


Bjarni
--

                        INFORMATION WANTS TO BE FREE

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Interactiveness

Tony Plate-3
Bjarni Juliusson wrote:

> Prof Brian Ripley wrote:
>  
>> On Tue, 11 Dec 2007, Bjarni Juliusson wrote:
>>    
>>> I'm developing R integration for a project called Bioclipse at Uppsala
>>> University. The current implementation works by simply forking an R and
>>> sending it text (with some substitutions on it) down a pipe, getting the
>>> printed output back up another pipe. This of course works fine, except
>>> it runs into one problem: R finds a pipe on its stdin and decides to be
>>> "non-interactive", which means that as soon as the user makes a typo and
>>> causes an error, R exits.
>>>      
>> Actually, not so.  The default error handler for non-interactive use is
>> to do that, but you can change it.
>>    
>
> Could you perhaps just point me in the right direction here? I really
> have no idea how to do this.
>  
Specify a non-NULL error handler by doing something like this:
 > options(error=dump.frames)
See ?options (look for "error") and ?stop for more details.

-- Tony Plate

> Also, what exactly does non-interactive mode imply, besides this default
> error handling behaviour?
>
>  
>>> I checked the source, and it's a couple of isatty()'s in the two files
>>> named system.c that are doing it. They are of course intended to be a
>>> feature, but in this case it causes us trouble. Would it be possible to
>>> get a command line switch to control this behaviour? I'm not sure pseudo
>>> terminals can be used portably, or can they?
>>>      
>> They can, and are e.g. by ESS (except on Windows, where there is already
>> a switch).  I think you need to look a bit more carefully at what other
>> projects do.
>>    
>
> It needs to be portable to Windows. I'll look into this possibility next.
>
> Didn't mean to ask before I had done my homework. Thanks for your help!
>
>
> Bjarni
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Interactiveness

Gregory Warnes

You might also find many of the tools provided in the 'session'  
package helpful for interacting with R in this way.

'session' package description:

Utility functions for interacting with R processes from external  
programs. This package includes functions to save and restore session  
information (including loaded packages, and attached data objects),  
as well as functions to evaluate strings containing R commands and  
return the printed results or an execution transcript.

-Greg


On Dec 11, 2007, at 1:18PM , Tony Plate wrote:

> Bjarni Juliusson wrote:
>> Prof Brian Ripley wrote:
>>
>>> On Tue, 11 Dec 2007, Bjarni Juliusson wrote:
>>>
>>>> I'm developing R integration for a project called Bioclipse at  
>>>> Uppsala
>>>> University. The current implementation works by simply forking  
>>>> an R and
>>>> sending it text (with some substitutions on it) down a pipe,  
>>>> getting the
>>>> printed output back up another pipe. This of course works fine,  
>>>> except
>>>> it runs into one problem: R finds a pipe on its stdin and  
>>>> decides to be
>>>> "non-interactive", which means that as soon as the user makes a  
>>>> typo and
>>>> causes an error, R exits.
>>>>
>>> Actually, not so.  The default error handler for non-interactive  
>>> use is
>>> to do that, but you can change it.
>>>
>>
>> Could you perhaps just point me in the right direction here? I really
>> have no idea how to do this.
>>
> Specify a non-NULL error handler by doing something like this:
>> options(error=dump.frames)
> See ?options (look for "error") and ?stop for more details.
>
> -- Tony Plate
>
>> Also, what exactly does non-interactive mode imply, besides this  
>> default
>> error handling behaviour?
>>
>>
>>>> I checked the source, and it's a couple of isatty()'s in the two  
>>>> files
>>>> named system.c that are doing it. They are of course intended to  
>>>> be a
>>>> feature, but in this case it causes us trouble. Would it be  
>>>> possible to
>>>> get a command line switch to control this behaviour? I'm not  
>>>> sure pseudo
>>>> terminals can be used portably, or can they?
>>>>
>>> They can, and are e.g. by ESS (except on Windows, where there is  
>>> already
>>> a switch).  I think you need to look a bit more carefully at what  
>>> other
>>> projects do.
>>>
>>
>> It needs to be portable to Windows. I'll look into this  
>> possibility next.
>>
>> Didn't mean to ask before I had done my homework. Thanks for your  
>> help!
>>
>>
>> Bjarni
>>
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel