diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/Dpkg/IPC.pm | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/scripts/Dpkg/IPC.pm b/scripts/Dpkg/IPC.pm index 116051d32..8d37c7047 100644 --- a/scripts/Dpkg/IPC.pm +++ b/scripts/Dpkg/IPC.pm @@ -78,11 +78,11 @@ dup'ed from the handle. =item from_pipe, to_pipe, error_to_pipe -Scalar reference. A pipe will be opened for each of the two options -and either the reading (C<to_pipe> and C<error_to_pipe>) or the writing -end (C<from_pipe>) will be returned in the referenced scalar. Standard -input/output/error of the child process will be dup'ed to the other ends -of the pipes. +Scalar reference or object based on IO::Handle. A pipe will be opened for +each of the two options and either the reading (C<to_pipe> and +C<error_to_pipe>) or the writing end (C<from_pipe>) will be returned in +the referenced scalar. Standard input/output/error of the child process +will be dup'ed to the other ends of the pipes. =item from_string, to_string, error_to_string @@ -146,15 +146,21 @@ sub _sanity_check_opts { internerr("not more than one of from_* parameters is allowed") if $from > 1; - foreach (qw(to_string error_to_string from_string - to_pipe error_to_pipe from_pipe)) - { + foreach (qw(to_string error_to_string from_string)) { if (exists $opts{$_} and (!ref($opts{$_}) or ref($opts{$_}) ne 'SCALAR')) { internerr("parameter $_ must be a scalar reference"); } } + foreach (qw(to_pipe error_to_pipe from_pipe)) { + if (exists $opts{$_} and + (!ref($opts{$_}) or (ref($opts{$_}) ne 'SCALAR' and + not $opts{$_}->isa("IO::Handle")))) { + internerr("parameter $_ must be a scalar reference or an IO::Handle object"); + } + } + if (exists $opts{"timeout"} and defined($opts{"timeout"}) and $opts{"timeout"} !~ /^\d+$/) { internerr("parameter timeout must be an integer"); |