-- "impatient.setl" (highly cautious version) if (pump_fd := pump()) = -1 then -- Child (worker), deals with inherited client stream fd := open (val command_line(1), 'rw'); -- inherited stream while (line := getline fd) /= om loop printa (fd, #line); -- send line length to client print; flush(stdout); -- make monitoring parent happy end loop; stop; -- all done elseif pump_fd /= om then -- Parent (monitor) continues here loop -- cycle until EOF on pump_fd or timeout [ready] := select ([{pump_fd}], 15 * 60 * 1000); if pump_fd in ready then if getline pump_fd = om then stop; -- child exited normally, and so do we end if; else -- timeout (nothing from pump_fd in 15 minutes) kill (pid (pump_fd)); -- send TERM signal to child stop; -- presume child exited, and do likewise end if; end loop; else -- No child was created printa (stderr, 'pump() failed, dropping client'); end if;