bug-readline
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-readline] terminal corruption with spawned ruby processes


From: Eric Thompson
Subject: Re: [Bug-readline] terminal corruption with spawned ruby processes
Date: Thu, 27 Apr 2017 16:46:30 -0700



On Wed, Apr 12, 2017 at 1:17 PM, Chet Ramey <address@hidden> wrote:
On 4/12/17 3:57 PM, Eric Thompson wrote:
>
>
> On Wed, Apr 12, 2017 at 12:14 PM, Chet Ramey <address@hidden
> <mailto:address@hidden>> wrote:
>
>     On 4/11/17 5:22 PM, Eric Thompson wrote:
>     > Hi all,
>     >    I ran into a possible problem in readline developing a library for Rake
>     > to aid in managing and launching processes.
>     >
>     > basically, if you use (ruby) Process.spawn or other ways to launch a
>     > subprocess that don't detach and that process inherits the stdin default
>     > pipe of the parent, the terminal input gets corrupted before hitting the
>     > child process (if that child is using readline).
>
>     This seems unwise, since ruby appears to use vfork(2).  As soon as the
>     child performs an execve, the parent wakes up again and tries to read
>     from the terminal.  At that point, you have `irb' and `pry' fighting
>     over input and reading inconsistent terminal settings.
>
>
> i just use irb as the simple reproducer.  you can get terminal corruption
> when running in nested `ruby -e` invocations as well. in my actual
> application we go to great pains to not allow inputs to stdin from the parent.

If they use vfork(), they will all result in multiple processes running
and fighting over the terminal. `irb' just happened to be running when
you used spawn, which uses vfork.  A system call trace shows this pretty
conclusively.

So give me another reproducer.

i finally got back around to this.

you are absolutely right, of course!
if i do the spawn of pry/irb straight from ruby it works fine.  i'm not sure what i was seeing before. 

thanks!


--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/



--
eric thompson                             engineering
(hc)erict             (t)@er0ck             (gh)er0ck

¤--¤ puppet:                           The shortest path to better software.
PuppetConf 2017, 10-12 October
San Francisco, California
Save $328, register by 30 June w/ early adopter discount

reply via email to

[Prev in Thread] Current Thread [Next in Thread]