NAME

Proc::PidChange - execute callbacks when PID changes

VERSION

version 0.002

SYNOPSIS

use Proc::PidChange;

## check for pid changes
check_current_pid();

## Registration of callbacks
use Proc::PidChange ':all';

register_pid_change_callback(sub { ... });

DESCRIPTION

This module provides a simple API to check if the process ID changed, due to a fork() call. If such change is detected, it calls all the registered callbacks.

The detection of PID changes can be done in two ways: in real-time as soon as it changes, or by calling "check_current_pid" on a regular basis. The real-time version requires the POSIX::AtFork module.

Interested parties should use the "register_pid_change_callback" to register a CodeRef to be called when the PID change is detected.

About real-time PID changes

Given that real-time is the most efficient method to detect PID changes, we aggresively try to load POSIX::AtFork module and if found, enable real-time PID detection.

You can check to see if real-time detection is being used with the $Proc::PidChange::RT variable. If true, real-time detection is available.

You can disable real-time detection by setting the PROC_PIDCHANGE_NO_RT environment to true before loading Proc::PidChange.

Be aware that you should add POSIX::AtFork to your dependencies, this modules doesn't require it.

FUNCTIONS

check_current_pid

Check the current PID to see if it's changed. If yes, calls all registered callbacks.

register_pid_change_callback

Register one or more callbacks to be called when the PID change is detected.

If you register the same CodeRef callback twice, it will be called twice.

unregister_pid_change_callback

Unregister one or more callbacks.

SEE ALSO

POSIX::AtFork

SUPPORT

Perldoc

You can find documentation for this module with the perldoc command.

perldoc Proc::PidChange

Websites

The following websites have more information about this module, and may be of help to you. As always, in addition to those websites please use your favorite search engine to discover more resources.

Email

You can email the author of this module at MELO at cpan.org asking for help with any problems you have.

Bugs / Feature Requests

Please report any bugs or feature requests by email to bug-proc-pidchange at rt.cpan.org, or through the web interface at http://rt.cpan.org/Public/Dist/Display.html?Name=Proc-PidChange. You will be automatically notified of any progress on the request by the system.

Source Code

https://github.com/melo/Proc-PidChange

git clone https://github.com/melo/Proc-PidChange.git

AUTHOR

Pedro Melo <melo@cpan.org>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2012 by Pedro Melo.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)