You do NOT want to use `fork`. MoarVM has several threads that are running, and `fork` doesn't handle that.
A simple way is to just use the `start` statement prefix sub child-process () { sleep 2; say 'child says hi' } say 'starting child'; start child-process(); for ^10 { say ++$; sleep .5; } say 'ending program'; Which will result in something like: starting child 1 2 3 4 child says hi 5 6 7 8 9 10 ending program The program will exit when the mainline finishes. So if you didn't have the loop, the program will exit before the child prints anything. You could directly call `$*SCHEDULER.cue(&child-process)` instead. Which has adverbs such as `every`, `times`, `at`, `in`, and `catch` If you use one of the adverbs other than `catch`, it will return a Cancellation object which would allow you to stop a thread that hasn't started running yet. On Tue, Apr 7, 2020 at 4:19 PM yary <not....@gmail.com> wrote: > They way I remember it (taught to me waaay back when) is that, you fork > twice, and the grandchild process that lives on becomes a daemon whose > parent is the system "init" process, PID 1, after the parent and > 1st-generation child process exit. Found general concept at > http://www.farhadsaberi.com/perl/2013/02/perl-detach-process-daemon.html > > How to implement that in raku, and if it works as intended in Windows... > is left as an exercise to the reader! > > -y > > > On Tue, Apr 7, 2020 at 2:42 PM Paul Procacci <pproca...@gmail.com> wrote: > >> https://docs.perl6.org/language/5to6-perlfunc#fork >> https://docs.perl6.org/type/Thread >> >> I haven't tried myself but it's conceivable that you can start a new >> thread that exec's some external program. >> >> On Tue, Apr 7, 2020 at 7:21 AM ToddAndMargo via perl6-users < >> perl6-us...@perl.org> wrote: >> >>> Hi All, >>> >>> Can a subroutine be released from the main program >>> to go off on its own? (Is this called "forked"?) >>> >>> If not how do I do a `qqx` or a `run` that releases >>> the program to go off on its own? >>> >>> Many thanks, >>> -T >>> >> >> >> -- >> __________________ >> >> :(){ :|:& };: >> >