yihui / runr

Run external programs from R (experimental)
85 stars 31 forks source link

Error in close.connection(con) : ignoring SIGPIPE signal for bash #7

Open lyonsquark opened 9 years ago

lyonsquark commented 9 years ago

Hi - I'm having trouble with the persistent bash feature. For example,

> library(runr)
> b = proc_bash()
> b$start()
> b$exec("x=3")
Error in close.connection(con) : ignoring SIGPIPE signal

A subsequent attempt at b$exec(...) will hang.

I'm running OSX Mavericks. Have you seen this behavior? Thanks! -- Adam

yihui commented 9 years ago

Yes, I tried it a while ago on OS X and failed to run bash code. I do not know why, though. It will be great if you can help me investigate this issue, since I do not use OS X very often.

lyonsquark commented 9 years ago

Thanks for your reply, Yihui, I did some experimentation, running code similar to your bash "server" reading from a named pipe that I would echo to from another bash session. Named pipes must be very finicky in OSX. Everything I tried failed most of the time, except every now and then it would work once or twice. I was able to improve things by using the bash builtin "read" command (reads only one line) and adding short sleeps (like 0.1 seconds). I was able to make that pretty reliable, but reading one line at a time makes building up the command you want to run difficult. In fact it seems impossible since "read" discards stuff past the first line. I'll play around some more and let you know what I figure out.

yihui commented 9 years ago

Thanks! How about using a socket server/client (e.g. http://hacktux.com/bash/socket) instead of named pipes? I have not tried utilities like nc (netcat) so I really do not know if they will work at all.

lyonsquark commented 9 years ago

Yes - I think sockets are the way to go. Looking into that...

lyonsquark commented 9 years ago

I think I have a working solution using sockets. Trying a few more things.

yihui commented 9 years ago

That sounds perfect! Thanks a lot! :+1:

lyonsquark commented 9 years ago

I think I've figured things out and sockets work fine on my Mac. I submitted a pull request to you with the changes. Please try them on Linux (or whatever you use) and let me know what happens. -- Adam

lyonsquark commented 9 years ago

Oops - didn't mean to close the issue :-)

lyonsquark commented 9 years ago

Ahh - sorry about using "tmp" - that was less than smart of me. Thanks for fixing it. -- Adam