--- deliantra/server/lib/cf.pm 2007/07/08 14:50:07 1.298 +++ deliantra/server/lib/cf.pm 2007/07/08 14:56:05 1.299 @@ -411,6 +411,15 @@ =cut +sub _store_scalar { + open my $fh, ">", \my $buf + or die "fork_call: cannot open fh-to-buf in child : $!"; + Storable::store_fd $_[0], $fh; + close $fh; + + $buf +} + sub fork_call(&@) { my ($cb, @args) = @_; @@ -435,22 +444,18 @@ reset_signals; local $SIG{__WARN__}; local $SIG{__DIE__}; + # just in case, this hack effectively disables event + # in the child. cleaner and slower would be canceling all watchers, + # but this works for the time being. local $Coro::idle; $Coro::current->prio (Coro::PRIO_MAX); + eval { close $fh1; my @res = eval { $cb->(@args) }; - open my $fh, ">", \my $buf - or die "fork_call: cannot open fh-to-buf in child : $!"; - Storable::store_fd +($@ ? \"$@" : \@res), $fh; - close $fh; - - warn "writing ", length $buf; - my $x; - (length $buf) == ($x = syswrite $fh2, $buf) - or warn "error writing ".(length $buf)." != $x\n"; + syswrite $fh2, _store_scalar $@ ? \"$@" : \@res; close $fh2; };