sub x_it ($$) { # pronounced "exit"
my ($self, $code) = @_;
+ $self->{1}->autoflush(1); # make sure client sees stdout before exit
if (my $sig = ($code & 127)) {
kill($sig, $self->{pid} // $$);
} else {
say $sock "timed out waiting to recv FDs";
return;
}
+ $self->{2}->autoflush(1); # keep stdout buffered until x_it|DESTROY
# $ARGV_STR = join("]\0[", @ARGV);
# $ENV_STR = join('', map { "$_=$ENV{$_}\0" } keys %ENV);
# $line = "$$\0\0>$ARGV_STR\0\0>$ENV_STR\0\0";
}, __PACKAGE__), @ARGV);
}
+# ensures stdout hits the FS before sock disconnects so a client
+# can immediately reread it
+sub DESTROY { $_[0]->{1}->autoflush(1) }
+
1;