NAME 

pidwatch - Run a command and if another PID exits, kill the command

SYNOPSIS 

  pidwatch [--cd I<cd>] --host <host> --pid <pid>  args[....]
  pidwatch [--cd I<cd>] --host <host> --pid <pid> --foreground <pid>

DESCRIPTION 

Chdir to the specified directory, if specified and possible, then run the arguments as a command in the foreground. When the foreground process exits, return its exit status. This is basically the same as running the command directly.

In the background, watch the foreground pid on the specified host. If pidstatd is running on the specified host, and the specified pid goes away, kill the foreground command.

Alternatively pass the PID of any process with --foreground, when that process exits, the background job exits; if the watched PID exits, the foreground pid is killed.

Common usage is to kill remote rsh children when a parent is kill -9ed. An example Perl application would invoke:

    system("rsh \$remote_host pidwatch"
           ." --cd \$ENV{PWD} --host \$ENV{HOST} --pid \$\$"
           ."\$remote_command...");

ARGUMENTS 

<parameters>
All non switch arguments after the switches are passed to /bin/sh as a -c argument. Thus passing ``a && b'' to pidwatch will result in pidwatch executing ``/bin/sh -c 'a && b'''.
--cd dir
Directory to chdir to.
--help
Displays this message and program version and exits.
--host host
Hostname to check for specified pid on. pidstatd must be running on that host to have this program be useful.
--killer program
Program to use instead of kill when it's time to terminate the pid. Will be passed arguments as if it was /bin/kill (program signame pid).
--foreground pid
Process ID to be killed when watched process exits. Used to watch a preexisting PID, instead of launching commands under a shell.
--pid pid
Process ID to watch. When this pid exits, the program will kill the foreground process.
--port port
Port of pidstatd server on remote host.
--signal signame
Signal number/name to send to process on remote PIDs death. Defaults to -HUP.

DISTRIBUTION 

The latest version is available from CPAN and from <http://www.veripool.com/>.

Copyright 2002-2006 by Wilson Snyder. This package is free software; you can redistribute it and/or modify it under the terms of either the GNU Lesser General Public License or the Perl Artistic License.

AUTHORS 

Wilson Snyder <wsnyder@wsnyder.org>

SEE ALSO 

IPC::Locker, IPC::PidStat, pidstat, pidstatd