1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797
|
package Proc::Background;
$Proc::Background::VERSION = '1.32';
# ABSTRACT: Generic interface to Unix and Win32 background process management
require 5.004_04;
use strict;
use Exporter;
use Carp;
use Cwd;
use Scalar::Util;
@Proc::Background::ISA = qw(Exporter);
@Proc::Background::EXPORT_OK = qw(timeout_system);
# Determine if the operating system is Windows.
my $is_windows = $^O eq 'MSWin32';
my $weaken_subref = Scalar::Util->can('weaken');
# Set up a regular expression that tests if the path is absolute and
# if it has a directory separator in it. Also create a list of file
# extensions of append to the programs name to look for the real
# executable.
my $is_absolute_re;
my $has_dir_element_re;
my $path_sep;
my @extensions = ('');
if ($is_windows) {
$is_absolute_re = '^(?:(?:[a-zA-Z]:[\\\\/])|(?:[\\\\/]{2}\w+[\\\\/]))';
$has_dir_element_re = "[\\\\/]";
$path_sep = "\\";
push(@extensions, '.exe');
} else {
$is_absolute_re = "^/";
$has_dir_element_re = "/";
$path_sep = "/";
}
# Make this class a subclass of Proc::Win32 or Proc::Unix. Any
# unresolved method calls will go to either of these classes.
if ($is_windows) {
require Proc::Background::Win32;
unshift(@Proc::Background::ISA, 'Proc::Background::Win32');
} else {
require Proc::Background::Unix;
unshift(@Proc::Background::ISA, 'Proc::Background::Unix');
}
# Take either a relative or absolute path to a command and make it an
# absolute path.
sub _resolve_path {
my $command = shift;
return ( undef, 'empty command string' ) unless length $command;
# Make the path to the progam absolute if it isn't already. If the
# path is not absolute and if the path contains a directory element
# separator, then only prepend the current working to it. If the
# path is not absolute, then look through the PATH environment to
# find the executable. In all cases, look for the programs with any
# extensions added to the original path name.
my $path;
if ($command =~ /$is_absolute_re/o) {
foreach my $ext (@extensions) {
my $p = "$command$ext";
if (-f $p and -x _) {
$path = $p;
last;
}
}
return defined $path? ( $path, undef ) : ( undef, "no executable program located at $command" );
} else {
my $cwd = cwd;
if ($command =~ /$has_dir_element_re/o) {
my $p1 = "$cwd$path_sep$command";
foreach my $ext (@extensions) {
my $p2 = "$p1$ext";
if (-f $p2 and -x _) {
$path = $p2;
last;
}
}
} else {
foreach my $dir (split($is_windows ? ';' : ':', $ENV{PATH})) {
next unless length $dir;
$dir = "$cwd$path_sep$dir" unless $dir =~ /$is_absolute_re/o;
my $p1 = "$dir$path_sep$command";
foreach my $ext (@extensions) {
my $p2 = "$p1$ext";
if (-f $p2 and -x _) {
$path = $p2;
last;
}
}
last if defined $path;
}
}
return defined $path? ( $path, undef ) : ( undef, "cannot find absolute location of $command" );
}
}
# Define the set of allowed options, to warn about unknown ones.
# Make it a method so subclasses can override it.
%Proc::Background::_available_options= (
autodie => 1, command => 1, exe => 1,
cwd => 1, stdin => 1, stdout => 1, stderr => 1,
autoterminate => 1, die_upon_destroy => 1,
);
sub _available_options {
return \%Proc::Background::_available_options;
}
# We want the created object to live in Proc::Background instead of
# the OS specific class so that generic method calls can be used.
sub new {
my $class = shift;
# The parameters are an optional %options hashref followed by any number
# of arguments to become the @argv for exec(). If options are given, check
# the keys for typos.
my $options;
if (@_ and ref $_[0] eq 'HASH') {
$options= shift;
my $known= $class->_available_options;
my @unknown= grep !$known->{$_}, keys %$options;
carp "Unknown options: ".join(', ', @unknown)
if @unknown;
}
else {
$options= {};
}
my $self= bless {}, $class;
$self->{_autodie}= 1 if $options->{autodie};
# Resolve any confusion between the 'command' option and positional @argv params.
# Store the command in $self->{_command} so that the ::Unix and ::Win32 don't have
# to deal with it redundantly.
my $cmd= $options->{command};
if (defined $cmd) {
croak "Can't use both 'command' option and command argument list"
if @_;
# Can be an arrayref or a single string
croak "command must be a non-empty string or an arrayref of strings"
unless (ref $cmd eq 'ARRAY' && defined $cmd->[0] && length $cmd->[0])
or (!ref $cmd && defined $cmd && length $cmd);
}
else {
# Back-compat: maintain original API quirks
confess "Proc::Background::new called with insufficient number of arguments"
unless @_;
return $self->_fatal('command is undefined') unless defined $_[0];
# Interpret the parameters as an @argv if there is more than one,
# or if the 'exe' option was given.
$cmd= (@_ > 1 || defined $options->{exe})? [ @_ ] : $_[0];
}
$self->{_command}= $cmd;
$self->{_exe}= $options->{exe} if defined $options->{exe};
# Also back-compat: failing to fork or CreateProcess returns undef
return unless $self->_start($options);
# Save the start time
$self->{_start_time} = time;
if ($options->{autoterminate} || $options->{die_upon_destroy}) {
$self->autoterminate(1);
}
return $self;
}
# The original API returns undef from the constructor in case of various errors.
# The autodie option converts these undefs into exceptions.
sub _fatal {
my ($self, $message)= @_;
croak $message if $self->{_autodie};
warn "$0: $message";
return undef;
}
sub autoterminate {
my ($self, $newval)= @_;
if (@_ > 1 and ($newval xor $self->{_die_upon_destroy})) {
if ($newval) {
# Global destruction can break this feature, because there are no guarantees
# on which order object destructors are called. In order to avoid that, need
# to run all the ->die methods during END{}, and that requires weak
# references which weren't available until 5.8
$weaken_subref->( $Proc::Background::_die_upon_destroy{$self+0}= $self )
if $weaken_subref;
# could warn about it for earlier perl... but has been broken for 15 years and
# who is still using < 5.8 anyway?
}
else {
delete $Proc::Background::_die_upon_destroy{$self+0};
}
$self->{_die_upon_destroy}= $newval? 1 : 0;
}
$self->{_die_upon_destroy} || 0
}
sub DESTROY {
my $self = shift;
if ($self->{_die_upon_destroy}) {
# During a mainline exit() $? is the prospective exit code from the
# parent program. Preserve it across any waitpid() in die()
local $?;
$self->terminate;
delete $Proc::Background::_die_upon_destroy{$self+0};
}
}
END {
# Child processes need killed before global destruction, else the
# Win32::Process objects might get destroyed first.
for (grep defined, values %Proc::Background::_die_upon_destroy) {
$_->terminate;
delete $_->{_die_upon_destroy}
}
%Proc::Background::_die_upon_destroy= ();
}
# Reap the child. If the first argument is false, then return immediately.
# Else, block waiting for the process to exit. If no second argument is
# given, wait forever, else wait for that number of seconds.
# If the wait was sucessful, then delete
# $self->{_os_obj} and set $self->{_exit_value} to the OS specific
# class return of _reap. Return 1 if we sucessfully waited, 0
# otherwise.
sub _reap {
my ($self, $blocking, $wait_seconds) = @_;
return 0 unless exists($self->{_os_obj});
# Try to wait on the process. Use the OS dependent wait call using
# the Proc::Background::*::waitpid call, which returns one of three
# values.
# (0, exit_value) : sucessfully waited on.
# (1, undef) : process already reaped and exit value lost.
# (2, undef) : process still running.
my ($result, $exit_value) = $self->_waitpid($blocking, $wait_seconds);
if ($result == 0 or $result == 1) {
$self->{_exit_value} = defined($exit_value) ? $exit_value : 0;
delete $self->{_os_obj};
# Save the end time of the class.
$self->{_end_time} = time;
return 1;
}
return 0;
}
sub alive {
my $self = shift;
# If $self->{_os_obj} is not set, then the process is definitely
# not running.
return 0 unless exists($self->{_os_obj});
# If $self->{_exit_value} is set, then the process has already finished.
return 0 if exists($self->{_exit_value});
# Try to reap the child. If it doesn't reap, then it's alive.
!$self->_reap(0);
}
sub suspended {
$_[0]->{_suspended}? 1 : 0
}
sub suspend {
my $self= shift;
return $self->_fatal("can't suspend, process has exited")
if !$self->{_os_obj};
$self->{_suspended} = 1 if $self->_suspend;
return $self->{_suspended};
}
sub resume {
my $self= shift;
return $self->_fatal("can't resume, process has exited")
if !$self->{_os_obj};
$self->{_suspended} = 0 if $self->_resume;
return !$self->{_suspended};
}
sub wait {
my ($self, $timeout_seconds) = @_;
# If $self->{_exit_value} exists, then we already waited.
return $self->{_exit_value} if exists($self->{_exit_value});
carp "calling ->wait on a suspended process" if $self->{_suspended};
# If neither _os_obj or _exit_value are set, then something is wrong.
return undef if !exists($self->{_os_obj});
# Otherwise, wait for the process to finish.
return $self->_reap(1, $timeout_seconds)? $self->{_exit_value} : undef;
}
sub terminate { shift->die(@_) }
sub die {
my $self = shift;
croak "process is already terminated" if $self->{_autodie} && !$self->{_os_obj};
# See if the process has already died.
return 1 unless $self->alive;
# Kill the process using the OS specific method.
$self->_terminate(@_? ([ @_ ]) : ());
# See if the process is still alive.
!$self->alive;
}
sub command {
$_[0]->{_command};
}
sub exe {
$_[0]->{_exe}
}
sub start_time {
$_[0]->{_start_time};
}
sub exit_code {
return undef unless exists $_[0]->{_exit_value};
return $_[0]->{_exit_value} >> 8;
}
sub exit_signal {
return undef unless exists $_[0]->{_exit_value};
return $_[0]->{_exit_value} & 127;
}
sub end_time {
$_[0]->{_end_time};
}
sub pid {
$_[0]->{_pid};
}
sub timeout_system {
unless (@_ > 1) {
confess "$0: timeout_system passed too few arguments.\n";
}
my $timeout = shift;
unless ($timeout =~ /^\d+(?:\.\d*)?$/ or $timeout =~ /^\.\d+$/) {
confess "$0: timeout_system passed a non-positive number first argument.\n";
}
my $proc = Proc::Background->new(@_) or return;
my $end_time = $proc->start_time + $timeout;
my $delay= $timeout;
while ($delay > 0 && defined $proc->{_os_obj}) {
last if defined $proc->wait($delay);
# If it times out, it's likely that wait() already waited the entire duration.
# But, if it got interrupted, there might be time remaining.
# But, if the system clock changes, this could break horribly. Constrain it to a sane value.
my $t= time;
if ($t < $end_time - $delay) { # time moved backward!
$end_time= $t + $delay;
} else {
$delay= $end_time - $t;
}
}
my $alive = $proc->alive;
$proc->terminate if $alive;
if (wantarray) {
return ($proc->wait, $alive);
} else {
return $proc->wait;
}
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Proc::Background - Generic interface to Unix and Win32 background process management
=head1 SYNOPSIS
use Proc::Background 'timeout_system';
timeout_system($seconds, $command, $arg1, $arg2);
timeout_system($seconds, "$command $arg1 $arg2");
my $proc1 = Proc::Background->new($command, $arg1, $arg2) || die "failed";
my $proc2 = Proc::Background->new("$command $arg1 1>&2") || die "failed";
if ($proc1->alive) {
$proc1->terminate;
$proc1->wait;
}
say 'Ran for ' . ($proc1->end_time - $proc1->start_time) . ' seconds';
Proc::Background->new({
autodie => 1, # Throw exceptions instead of returning undef
cwd => 'some/path/', # Set working directory for the new process
exe => 'busybox', # Specify executable different from argv[0]
command => [ $command ] # resolve ambiguity of command line vs. argv[0]
});
# Set initial file handles
Proc::Background->new({
stdin => undef, # /dev/null or NUL
stdout => '/append/to/fname', # will try to open()
stderr => $log_fh, # use existing handle
command => \@command,
});
# Automatically kill the process if the object gets destroyed
my $proc4 = Proc::Background->new({ autoterminate => 1 }, $command);
$proc4 = undef; # calls ->terminate
=head1 DESCRIPTION
This is a generic interface for placing processes in the background on
both Unix and Win32 platforms. This module lets you start, kill, wait
on, retrieve exit values, and see if background processes still exist.
=head1 CONSTRUCTOR
=over 4
=item B<new> [options] I<command>, [I<arg>, [I<arg>, ...]]
=item B<new> [options] 'I<command> [I<arg> [I<arg> ...]]'
This creates a new background process. Just like C<system()>, you can
supply a single string of the entire command line, or individual
arguments. The first argument may be a hashref of named options.
To resolve the ambiguity between a command line vs. a single-element
argument list, see the C<command> option below.
By default, the constructor returns an empty list on failure,
except for a few cases of invalid arguments which call C<croak>.
For platform-specific details, see L<Proc::Background::Unix/IMPLEMENTATION>
or L<Proc::Background::Win32/IMPLEMENTATION>, but in short:
=over 7
=item Unix
This implementation uses C<fork>/C<exec>. If you supply a single-string
command line, it is passed to the shell. If you supply multiple arguments,
they are passed to C<exec>. In the multi-argument case, it will also check
that the executable exists before calling C<fork>.
=item Win32
This implementation uses the L<Windows CreateProcess API|Win32::Process/METHODS>.
If you supply a single-string command line, it derives the executable by
parsing the command line and looking for the first element in the C<PATH>,
appending C<".exe"> if needed. If you supply multiple arguments, the
first is used as the C<exe> and the command line is built using
L<Win32::ShellQuote>. To let Windows search for the executable, pass option
C<< { exe => undef } >>.
=back
B<Options:>
=over
=item C<autodie>
This module traditionally has returned C<undef> if the child could not
be started. Modern Perl recommends the use of exceptions for things
like this. This option, like Perl's L<autodie> pragma, causes all
fatal errors in starting the process to die with exceptions instead of
returning undef. (module-usage errors or other problems prior to
launching the process may still 'croak' regardless of this setting)
=item C<command>
You may specify the command as an option instead of passing the command
as a list. A string value is considered a command line, and an arrayref
value is considered an argument list. Using this option resolves the
ambiguity in the plain-list constructor between a command line vs.
a single-element argument list.
=item C<exe>
Specify the executable. This can serve two purposes:
on Win32 it avoids the need to parse the commandline, and on Unix it can be
used to run an executable while passing a different value for C<$ARGV[0]>.
=item C<stdin>, C<stdout>, C<stderr>
Specify one or more overrides for the standard handles of the child.
The value should be a Perl filehandle with an underlying system C<fileno>
value. As a convenience, you can pass C<undef> to open the C<NUL> device
on Win32 or C</dev/null> on Unix. You may also pass a plain-scalar file
name which this module will attmept to open for reading or appending.
(for anything more elaborate, see L<IPC::Run> instead)
Note that on Win32, none of the parent's handles are inherited by default,
which is the opposite on Unix. When you specify any of these handles on
Win32 the default will change to inherit the rest from the parent.
=item C<cwd>
Specify a path which should become the child process's current working
directory. The path must already exist.
=item C<autoterminate>
If you pass a true value for this option, then destruction of the
Proc::Background object (going out of scope, or script-end) will kill the
process via C<< ->terminate >>. Without this option, the child process
continues running. C<die_upon_destroy> is an alias for this option, used
by previous versions of this module.
=back
=back
=head1 ATTRIBUTES
=over
=item B<command>
The command (string or arrayref) that was passed to the constructor.
=item B<exe>
The path to the executable that was passed as an option to the constructor,
or derived from the C<command>.
=item B<start_time>
Return the value that the Perl function time() returned when the
process was started.
=item B<pid>
Returns the process ID of the created process. This value is saved
even if the process has already finished.
=item B<alive>
Return 1 if the process is still active, 0 otherwise. This makes a
non-blocking call to C<wait> to check the real status of the process if it
has not been reaped yet.
=item B<suspended>
Boolean whether the process is thought to be stopped. This does not actually
consult the operating system, and just returns the last known status from a
call to C<suspend> or C<resume>. It is always false if C<alive> is false.
=item B<exit_code>
Returns the exit code of the process, assuming it exited cleanly.
Returns C<undef> if the process has not exited yet, and 0 if the
process exited with a signal (or TerminateProcess). Since 0 is
ambiguous, check for C<exit_signal> first.
=item B<exit_signal>
Returns the value of the signal the process exited with, assuming it
died on a signal. Returns C<undef> if it has not exited yet, and 0
if it did not die to a signal.
=item B<end_time>
Return the value that the Perl function time() returned when the exit
status was obtained from the process.
=item B<autoterminate>
This writeable attribute lets you enable or disable the autoterminate
option, which could also be passed to the constructor.
=back
=head1 METHODS
=over
=item B<wait>
$exit= $proc->wait; # blocks forever
$exit= $proc->wait($timeout_seconds); # since version 1.20
Wait for the process to exit. Return the exit status of the command
as returned by wait() on the system. To get the actual exit value,
divide by 256 or right bit shift by 8, regardless of the operating
system being used. If the process never existed, this returns undef.
This function may be called multiple times even after the process has
exited and it will return the same exit status.
Since version 1.20, you may pass an optional argument of the number of
seconds to wait for the process to exit. This may be fractional, and
if it is zero then the wait will be non-blocking. Note that on Unix
this is implemented with L<Time::HiRes/alarm> before a call to wait(),
so it may not be compatible with scripts that use alarm() for other
purposes, or systems/perls that resume system calls after a signal.
In the event of a timeout, the return will be undef.
=item B<suspend>
Pause the process. This returns true if the process is stopped afterward.
This throws an excetion if the process is not C<alive> and C<autodie> is
enabled.
=item B<resume>
Resume a paused process. This returns true if the process is not stopped
afterward. This throws an exception if the process is not C<alive> and
C<autodie> is enabled.
=item B<terminate>, B<terminate(@kill_sequence)>
Reliably try to kill the process. Returns 1 if the process no longer
exists once B<terminate> has completed, 0 otherwise. This will also return
1 if the process has already exited.
C<@kill_sequence> is a list of actions and seconds-to-wait for that
action to end the process. The default is C< TERM 2 TERM 8 KILL 3 KILL 7 >.
On Unix this sends SIGTERM and SIGKILL; on Windows it just calls
TerminateProcess (graceful termination is still a TODO).
Note that C<terminate()> (formerly named C<die()>) on Proc::Background 1.10
and earlier on Unix called a sequence of:
->die( ( HUP => 1 )x5, ( QUIT => 1 )x5, ( INT => 1 )x5, ( KILL => 1 )x5 );
which wasn't what most people need, since SIGHUP is open to interpretation,
and QUIT is almost always immediately fatal and generates a coredump.
The new default should accomodate programs that acknowledge a second
SIGTERM, and give enough time for it to exit on a laggy system while still
not holding up the main script too much.
C<die> is preserved as an alias for C<terminate>.
This throws an exception if the process has been reaped and C<autodie> is
enabled.
=back
=head1 FUNCTIONS
=over 4
=item B<timeout_system> I<timeout>, I<command>, [I<arg>, [I<arg>...]]
=item B<timeout_system> 'I<timeout> I<command> [I<arg> [I<arg>...]]'
Run a command for I<timeout> seconds and if the process did not exit,
then kill it.
In a scalar context, B<timeout_system> returns the exit status from
the process. In an array context, B<timeout_system> returns a two
element array, where the first element is the exist status from the
process and the second is set to 1 if the process was killed by
B<timeout_system> or 0 if the process exited by itself.
The exit status is the value returned from the wait() call. If the
process was killed, then the return value will include the killing of
it. To get the actual exit value, divide by 256.
If something failed in the creation of the process, the subroutine
returns an empty list in a list context, an undefined value in a
scalar context, or nothing in a void context.
=back
=head1 BUGS
The following behaviors aren't ideal, but are preserved for backward-compatibility.
=over
=item Commandline vs. Single Argv[]
C<< ->new($x) >> is treated as a command line. In C<< ->new({ exe => $y }, $x) >>,
$x is treated as C<$ARGV[0]>. Use C<< ->new({ command => ... }) >>
(scalar vs. arrayref) to dis-ambiguate.
=item Win32 Argv Quoting
This is a bug in Windows, not this module. It is not possible to universally
convert an @ARGV into a commandline, because each Win32 program performs its
own command line parsing, and cmd.exe and find.exe deviate from the majority
of other executables. Those things could be improved with hieuristics, which
this module doesn't have.
=item Win32 exe determination
If you don't specify an absolute path for option C<exe>, this module manually
searches the %PATH% looking for the executable, and is less thorough than the
native Windows shell behavior. Use C<< { exe => undef } >> to get the naive
Windows exe search. (but you need Win32::Process version 0.17 or newer)
=item Win32 SIGTERM
This module only supports TerminateProcess, which is equivalent to SIGKILL, not
SIGTERM. SIGTERM could be emulated by calling taskkill.exe, or using windows
messages. Patches welcome.
=back
=head1 SEE ALSO
=over
=item L<IPC::Run>
IPC::Run is a much more complete solution for running child processes.
It handles dozens of forms of redirection and pipe pumping, and should
probably be your first stop for any complex needs.
However, also note the very large and slightly alarming list of
limitations it lists for Win32. Proc::Background is a much simpler design
and should be more reliable for simple needs.
=item L<Win32::ShellQuote>
If you are running on Win32, this article by Daniel Colascione helps
describe the problem you are up against for passing argument lists:
L<Everyone quotes command line arguments the wrong way|https://blogs.msdn.microsoft.com/twistylittlepassagesallalike/2011/04/23/everyone-quotes-command-line-arguments-the-wrong-way/>
This module gives you parsing / quoting per the standard
CommandLineToArgvW behavior. But, if you need to pass arguments to be
processed by C<cmd.exe> then you need to do additional work.
=back
=head1 AUTHORS
=over 4
=item *
Blair Zajac <blair@orcaware.com>
=item *
Michael Conrad <mike@nrdvana.net>
=back
=head1 CONTRIBUTORS
=for stopwords Florian Schlichting Kevin Ryde Salvador Fandiño Sven Kirmess
=over 4
=item *
Florian Schlichting <fsfs@debian.org>
=item *
Kevin Ryde <user42@zip.com.au>
=item *
Salvador Fandiño <sfandino@yahoo.com>
=item *
Sven Kirmess <sven.kirmess@kzone.ch>
=back
=head1 VERSION
version 1.32
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2023 by Michael Conrad, (C) 1998-2009 by Blair Zajac.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
|