Possible bug: R --slave --interactive stdin echo on Linux when stdin is a fifo

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Possible bug: R --slave --interactive stdin echo on Linux when stdin is a fifo

Gábor Csárdi
I am trying to control a background R session, connected via a fifo /
named pipe.

The problem is, R --slave --interactive does not echo the input on
stdout on macOS and Windows, but it does echo it on Linux. This is
very unfortunate, because there is no easy way to separate the input
and the stdout of the R process here.

Here is how to reproduce it easily:

mkfifo fif
R --slave --interactive < fif > out &
(echo 1+1; echo '"foobar"') > fif
cat out

#> 1+1
#> [1] 2
#> "foobar"
#> [1] "foobar"

This is recent  R-devel, but at least 3.4.x has this behavior as well.

Would it be possible to eliminate the echo on Linux as well?

Thanks,
Gabor

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

Re: Possible bug: R --slave --interactive stdin echo on Linux when stdin is a fifo

barry rowlingson
On Thu, Jul 26, 2018 at 12:22 AM, Gábor Csárdi <[hidden email]> wrote:
> I am trying to control a background R session, connected via a fifo /
> named pipe.

 Is the fifo significant here? If I read the same R code from a file
via `<` I get the input echoed (R 3.4.4, Ubuntu).

Barry

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

Re: Possible bug: R --slave --interactive stdin echo on Linux when stdin is a fifo

Gábor Csárdi
On Thu, Jul 26, 2018 at 12:25 PM Barry Rowlingson
<[hidden email]> wrote:
>
> On Thu, Jul 26, 2018 at 12:22 AM, Gábor Csárdi <[hidden email]> wrote:
> > I am trying to control a background R session, connected via a fifo /
> > named pipe.
>
>  Is the fifo significant here? If I read the same R code from a file
> via `<` I get the input echoed (R 3.4.4, Ubuntu).

Yeah, for a file I get echo on both macOS and Linux, but not on Windows.

I think the most useful behavior for --slave is no echo at all, maybe?
But I might be missing the motivation behind --slave.

Another thing is that windows does not have --interactive. Is there a
way to run R
1) without echoing stdin, and
2) without quitting on the first error,
on all platforms?

Gabor

> Barry

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

Re: Possible bug: R --slave --interactive stdin echo on Linux when stdin is a fifo

luke-tierney
On Thu, 26 Jul 2018, Gábor Csárdi wrote:

> On Thu, Jul 26, 2018 at 12:25 PM Barry Rowlingson
> <[hidden email]> wrote:
>>
>> On Thu, Jul 26, 2018 at 12:22 AM, Gábor Csárdi <[hidden email]> wrote:
>>> I am trying to control a background R session, connected via a fifo /
>>> named pipe.
>>
>>  Is the fifo significant here? If I read the same R code from a file
>> via `<` I get the input echoed (R 3.4.4, Ubuntu).
>
> Yeah, for a file I get echo on both macOS and Linux, but not on Windows.
>
> I think the most useful behavior for --slave is no echo at all, maybe?
> But I might be missing the motivation behind --slave.
>
> Another thing is that windows does not have --interactive. Is there a
> way to run R
> 1) without echoing stdin, and

I'm not seeing an echo for your example on Ubuntu or Fedora.

> 2) without quitting on the first error,
> on all platforms?

One option is to use

     options(error = function() invokeRestart("abort"))

There may be better ways.

Best,

luke

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

--
Luke Tierney
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa                  Phone:             319-335-3386
Department of Statistics and        Fax:               319-335-3017
    Actuarial Science
241 Schaeffer Hall                  email:   [hidden email]
Iowa City, IA 52242                 WWW:  http://www.stat.uiowa.edu
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Possible bug: R --slave --interactive stdin echo on Linux when stdin is a fifo

Gábor Csárdi
On Thu, Jul 26, 2018 at 1:43 PM <[hidden email]> wrote:

>
> On Thu, 26 Jul 2018, Gábor Csárdi wrote:
>
> > On Thu, Jul 26, 2018 at 12:25 PM Barry Rowlingson
> > <[hidden email]> wrote:
> >>
> >> On Thu, Jul 26, 2018 at 12:22 AM, Gábor Csárdi <[hidden email]> wrote:
> >>> I am trying to control a background R session, connected via a fifo /
> >>> named pipe.
> >>
> >>  Is the fifo significant here? If I read the same R code from a file
> >> via `<` I get the input echoed (R 3.4.4, Ubuntu).
> >
> > Yeah, for a file I get echo on both macOS and Linux, but not on Windows.
> >
> > I think the most useful behavior for --slave is no echo at all, maybe?
> > But I might be missing the motivation behind --slave.
> >
> > Another thing is that windows does not have --interactive. Is there a
> > way to run R
> > 1) without echoing stdin, and
>
> I'm not seeing an echo for your example on Ubuntu or Fedora.

Interesting. Do you mean the fifo example, or just a file? Or both?
I wonder what this depends on then....

Particularly interesting that this does echo on macOS:
echo '1+1' | R --slave --interactive
But the FIFO example does not.

Anyway, it seems that if I remove --interactive then I get no echo.

> > 2) without quitting on the first error,
> > on all platforms?
>
> One option is to use
>
>      options(error = function() invokeRestart("abort"))

This seems good enough for my use case, thanks much!
Luckily, this also solves the "disabling the crash dialog" problem, which I
have if I specify --interactive.

Gabor

> There may be better ways.
>
> Best,
>
> luke
>
> >
> > Gabor
> >
> >> Barry
> >
> > ______________________________________________
> > [hidden email] mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
> >
>
> --
> Luke Tierney
> Ralph E. Wareham Professor of Mathematical Sciences
> University of Iowa                  Phone:             319-335-3386
> Department of Statistics and        Fax:               319-335-3017
>     Actuarial Science
> 241 Schaeffer Hall                  email:   [hidden email]
> Iowa City, IA 52242                 WWW:  http://www.stat.uiowa.edu

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

Re: Possible bug: R --slave --interactive stdin echo on Linux when stdin is a fifo

luke-tierney
On Thu, 26 Jul 2018, Gábor Csárdi wrote:

> On Thu, Jul 26, 2018 at 1:43 PM <[hidden email]> wrote:
>>
>> On Thu, 26 Jul 2018, Gábor Csárdi wrote:
>>
>>> On Thu, Jul 26, 2018 at 12:25 PM Barry Rowlingson
>>> <[hidden email]> wrote:
>>>>
>>>> On Thu, Jul 26, 2018 at 12:22 AM, Gábor Csárdi <[hidden email]> wrote:
>>>>> I am trying to control a background R session, connected via a fifo /
>>>>> named pipe.
>>>>
>>>>  Is the fifo significant here? If I read the same R code from a file
>>>> via `<` I get the input echoed (R 3.4.4, Ubuntu).
>>>
>>> Yeah, for a file I get echo on both macOS and Linux, but not on Windows.
>>>
>>> I think the most useful behavior for --slave is no echo at all, maybe?
>>> But I might be missing the motivation behind --slave.
>>>
>>> Another thing is that windows does not have --interactive. Is there a
>>> way to run R
>>> 1) without echoing stdin, and
>>
>> I'm not seeing an echo for your example on Ubuntu or Fedora.
>
> Interesting. Do you mean the fifo example, or just a file? Or both?
> I wonder what this depends on then....

The fifo one -- I didn't try a file.

>
> Particularly interesting that this does echo on macOS:
> echo '1+1' | R --slave --interactive
> But the FIFO example does not.
>
> Anyway, it seems that if I remove --interactive then I get no echo.

Looks like this has to do with readline, which --interactive turns on.
If I use '--no-readline --interactive' (in that order) on Mac OS and
Linux I get no echo.

The code in R for all this should be identical on Linux and Mac OS --
both use the unix code. readline libraries may differ, shell/stty
settings may differ for your setup.

Best,

luke

>
>>> 2) without quitting on the first error,
>>> on all platforms?
>>
>> One option is to use
>>
>>      options(error = function() invokeRestart("abort"))
>
> This seems good enough for my use case, thanks much!
> Luckily, this also solves the "disabling the crash dialog" problem, which I
> have if I specify --interactive.
>
> Gabor
>
>> There may be better ways.
>>
>> Best,
>>
>> luke
>>
>>>
>>> Gabor
>>>
>>>> Barry
>>>
>>> ______________________________________________
>>> [hidden email] mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>>
>>
>> --
>> Luke Tierney
>> Ralph E. Wareham Professor of Mathematical Sciences
>> University of Iowa                  Phone:             319-335-3386
>> Department of Statistics and        Fax:               319-335-3017
>>     Actuarial Science
>> 241 Schaeffer Hall                  email:   [hidden email]
>> Iowa City, IA 52242                 WWW:  http://www.stat.uiowa.edu
>

--
Luke Tierney
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa                  Phone:             319-335-3386
Department of Statistics and        Fax:               319-335-3017
    Actuarial Science
241 Schaeffer Hall                  email:   [hidden email]
Iowa City, IA 52242                 WWW:  http://www.stat.uiowa.edu
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Possible bug: R --slave --interactive stdin echo on Linux when stdin is a fifo

Gábor Csárdi
On Thu, Jul 26, 2018 at 2:47 PM <[hidden email]> wrote:
[...]
> Looks like this has to do with readline, which --interactive turns on.
> If I use '--no-readline --interactive' (in that order) on Mac OS and
> Linux I get no echo.

Great! Makes sense. Thanks much.

G.

[...]

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