# New Ticket Created by Brian Duggan # Please include the string: [perl #132170] # in the subject line of all future correspondence about this issue. # <URL: https://rt.perl.org/Ticket/Display.html?id=132170 >
When I export a function that does a fork() and then a react + whenever + IO::Socket::Async.listen in the child process, the process only seems to be listening on the socket the second time I run the code, i.e. only after .precomp has been written. To reproduce: 1. name the three files below 'try.sh', 'runme.p6' and 'Server.pm6'. 2. Run try.sh I see this output on linux: attempt 1 nc: connect to localhost port 3333 (tcp) failed: Connection refused attempt 2 Connection to localhost 3333 port [tcp/*] succeeded! And a similiar output on OS/X. Increasing the time of the sleep doesn't help. try.sh: #!/bin/sh rm -rf .precomp for i in 1 2; do echo "attempt $i" perl6 runme.p6 & sleep 5 echo 'Connecting' nc -v localhost 3333 echo 'Killing' killall moar done runme.p6: use lib '.'; use Server; start-fork; Server.pm6: use NativeCall; sub fork returns int32 is native { * }; sub start-fork is export { unless fork() { react whenever IO::Socket::Async.listen('localhost',3333) { exit; } } } Output of perl6 -v: This is Rakudo version 2017.08 built on MoarVM version 2017.08.1 implementing Perl 6.c.