USING: accessors command-line io io.encodings.binary io.pipes io.ports kernel math.parser native-thread-test sequences serialize io.backend.unix ; IN: pipe-race : pipe>output-handle ( pipe -- integer ) out>> handle>> fd>> ; : handle>output-stream ( integer -- stream ) ; : make-handle-arg ( handle -- str ) number>string "-handle=" prepend ; : read-forever ( -- ) [ deserialize "." write flush ] loop ; : run-test ( -- ) binary [ pipe>output-handle make-handle-arg { "-run=pipe-race" "-quiet" } swap suffix start-vm-in-os-thread drop ] [ [ read-forever ] with-input-stream* ] bi ; : child-main ( -- ) (command-line) [ "-handle=" head? ] find nip 8 tail string>number handle>output-stream [ [ "hello!" serialize flush t ] loop ] with-output-stream* ; MAIN: child-main