mirror of
https://github.com/pragma-/pbot.git
synced 2025-02-18 14:30:40 +01:00
ProcessManager: improve timed-out message
This commit is contained in:
parent
681438c27d
commit
6d2221e8f0
@ -75,9 +75,9 @@ sub execute_process {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pipe(my $reader, my $writer);
|
pipe(my $reader, my $writer);
|
||||||
my $pid = fork;
|
$stuff->{pid} = fork;
|
||||||
|
|
||||||
if (not defined $pid) {
|
if (not defined $stuff->{pid}) {
|
||||||
$self->{pbot}->{logger}->log("Could not fork process: $!\n");
|
$self->{pbot}->{logger}->log("Could not fork process: $!\n");
|
||||||
close $reader;
|
close $reader;
|
||||||
close $writer;
|
close $writer;
|
||||||
@ -86,7 +86,7 @@ sub execute_process {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($pid == 0) {
|
if ($stuff->{pid} == 0) {
|
||||||
# child
|
# child
|
||||||
close $reader;
|
close $reader;
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ sub execute_process {
|
|||||||
|
|
||||||
# execute the provided subroutine, results are stored in $stuff
|
# execute the provided subroutine, results are stored in $stuff
|
||||||
eval {
|
eval {
|
||||||
local $SIG{ALRM} = sub { die "PBot::Process timed-out" };
|
local $SIG{ALRM} = sub { die "PBot::Process `$stuff->{commands}->[0]` timed-out" };
|
||||||
alarm $timeout;
|
alarm $timeout;
|
||||||
$subref->($stuff);
|
$subref->($stuff);
|
||||||
die if $@;
|
die if $@;
|
||||||
@ -120,8 +120,8 @@ sub execute_process {
|
|||||||
} else {
|
} else {
|
||||||
# parent
|
# parent
|
||||||
close $writer;
|
close $writer;
|
||||||
$self->add_process($pid, $stuff);
|
$self->add_process($stuff->{pid}, $stuff);
|
||||||
$self->{pbot}->{select_handler}->add_reader($reader, sub { $self->process_pipe_reader($pid, @_) });
|
$self->{pbot}->{select_handler}->add_reader($reader, sub { $self->process_pipe_reader($stuff->{pid}, @_) });
|
||||||
# return empty string since reader will handle the output when child is finished
|
# return empty string since reader will handle the output when child is finished
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user