Kevin Ryde
and 1 contributors

NAME

App::Chart::Glib::Ex::ChildPid -- object holding child process ID

SYNOPSIS

 use App::Chart::Glib::Ex::ChildPid;
 my $pobj = App::Chart::Glib::Ex::ChildPid->new (pid => $pid);

 $pobj->kill ('INT');
 $pobj->terminate_with_timeout;

DESCRIPTION

A App::Chart::Glib::Ex::ChildPid holds the process ID (an integer) for a child process created by fork or similar spawn.

The fork and subprocess emulation described in perlfork doesn't work with Glib process watching (as of Perl-Glib 1.200) and cannot be used with App::Chart::Glib::Ex::ChildPid.

FUNCTIONS

$pobj->kill ()
$pobj->kill ($sig)

Send signal $sig to the $pobj process. $sig defaults to SIGTERM, otherwise it's a string or number per the core kill function (see "kill" in perlfunc).

$pobj->wait ()
$pobj->wait ($flags)

Block and wait for the $pobj process to terminate, as per the core waitpid. The exited signal is also emitted in the usual way if it terminates.

PROPERTIES

pid (integer, default 0)

The process ID held and operated on. It must be an immediate child of the current process, but can be started by either fork or any of the several Perl fork/spawn/open modules.

exited (boolean, default false)

The process ID held and operated on. It must be an immediate child of the current process, but can be started by either fork or any of the several Perl fork/spawn/open modules.

kill-on-destroy (boolean, default true)

If true then when the ChildPid object is destroyed through garbage collection the process is killed and waited if that hasn't already been done.

This is true by default to ensure the child process stops when the parent stops, or when you discard the object as no longer wanted.

SIGNALS

exited ($status)

Emitted when the child process exits, either normally or killed by a signal, but not when merely paused by SIGSTOP, SIGTSTP, etc.

This is implemented by a Glib::Child->add_watch (see Glib::MainLoop). Note that function uses SIGCHLD and if you install your own $SIG{'CHLD'} handler then exited won't run.

SEE ALSO

Glib::MainLoop, IPC::Open3, Proc::SyncExec

HOME PAGE

http://user42.tuxfamily.org/chart/index.html

LICENCE

Copyright 2008, 2009, 2010, 2011, 2016 Kevin Ryde

Chart is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

Chart is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Chart; see the file COPYING. Failing that, see http://www.gnu.org/licenses/.