Welcome to the main channel on the development of MoarVM, a virtual machine for NQP and Rakudo (moarvm.org). This channel is being logged for historical purposes.
Set by lizmat on 24 May 2021.
lizmat so, do we have a way to re-open STDIN when procing out? 19:29
case in point:
raku -e '$*IN.slurp; run "vim" < foo 19:30
raku -e '$*IN.slurp; run "vim"' < foo
I either get: Vim: Warning: Input is not from a terminal and a delay of ~ 2 seconds and "mouse droppings" in my terminal 19:31
or, if I close $*IN, I get:
The spawned command 'vim' exited unsuccessfully (exit code: 1, signal: 0) 19:32
japhb Well, if you are redirecting from a file, it is indeed not a terminal.
I suppose you could dry reopening on '/dev/tty', which should be the controlling terminal on Posix systems 19:33
*could try
lizmat that'd be hardly portable.. :-)
but it indeed does the right thing! 19:34
japhb lizmat: Portable to all the platforms that matter *cough*. ;-) 19:36
But seriously, it should even work under WSL2.
lizmat ok, then I'll use that for now
the idea being that you can: 19:37
raku foo.raku 2> 2(rak --backtrace --edit)
raku foo.raku 2> >(rak --backtrace --edit)
to run a raku script, and then be able to edit all the source locations of the stack trace 19:38
japhb ah yeah, makes sense 19:39
lizmat I sorta thought nqp::getstdin would do the right thing, but it doesn't seem to 19:44
japhb Well as far as its concerned, stdin is the redirect ... it's not paying attention to controlling terminal at that point. 19:47
(/dev/tty wasn't just a random hack -- that's apparently how you're Supposed To Do That) 19:48
nine Well, /dev/tty is only correct if STDIN was connected to the terminal before. If it was a pipe or a file, you'd still be off. The correct way is to dup() the file descriptor before closing it and later dup2() it back to STDIN 20:24
japhb nine: /dev/tty is, to my understanding, how you recover the controlling terminal when STDIN was connected to a pipe or file outside of your program's control. 21:43
MasterDuke any thoughts on github.com/MoarVM/MoarVM/pull/1723 ? 23:51
japhb MasterDuke: First, it's somewhat annoying how many files have to change just to replace a deprecated op with a live one. :-P Second, does libuv have any way to set *just one* of uid and gid, leaving the other unchanged? Read-update-write for chown seems like a race condition .... 23:57