Sympa::Process - Process of Sympa
use Sympa::Process;
my $process = Sympa::Process->instance;
$process->init(pidname => 'sympa');
$process->daemonize;
$process->fork;
Sympa::Process implements the class to handle process itself of Sympa software.
Once Sympa::Process is loaded, "SIGCHLD"
signals are captured, and only defunct child processes invoked by
fork() method are reaped.
- instance ( )
- Constructor. Creates a singleton instance of Sympa::Process object.
Returns:
A new Sympa::Process instance, or undef for
failure.
- init ( key => value, ... )
- Instance method. TBD.
- daemonize ( )
- Instance method. Daemonizes process itself. Process is given new
process group, detached from TTY and given new process ID.
Parameters:
None.
Returns:
None.
- fork ( [ $tag ] )
- Instance method. Forks process. Note that this method should be
used instead of fork() in Perl core.
Parameter:
- $tag
- A string to determine new child process. By default the name of calling
process.
Returns:
See "fork" in perlfunc.
- reap_child ( [ blocking => 1 ] )
- DEPRECATED.
- wait_child ( )
- Instance method. Waits for any child process.
Parameters:
None.
Returns:
0. Returns
"-1" on failure.
- sync_child ( [ hash => \%hash ], [ file => 1 ] )
- Updates process information in external data.
Parameters:
- hash => \%hash
- Syncs PIDs in local map %hash
- file => 1
- Syncs child PIDs in PID file. If dead PID is found, notification will be
sent to super-listmaster.
- remove_pid ([ pid => $pid ], [ final => 1 ] )
- Instance method. Removes process ID from PID file. Then if the file
is empty, it will be removed.
- write_pid ( [ initial => 1 ], [ pid => $pid ] )
- Instance method. Writes or adds process ID to PID file.
Parameters:
- initial => 1
- Initializes PID file. If the file remains, notification will be sent to
super-listmaster.
- pid => $pid
- Process ID to be written. By default PID of current process.
- direct_stderr_to_file ( )
- Instance method. TBD.
Sympa::Process instance may have following attributes:
- {children}
- Hashref with child PIDs forked by fork() method as keys.
- {detached}
- True value is set if daemonize() method was called and the process
has been detached from TTY.
- {generation}
- Generation of process. If fork() method succeeds, it will be
increased by child process.
- eval_in_time ( $subref, $timeout )
- Evaluate subroutine $subref in
$timeout seconds.
TBD.
- register_handler ( )
- Registers "SIGCHLD" handler. This
function is usually called automatically during initialization.
Sympa::Tools::Daemon appeared on Sympa 6.2a.41.
Renamed Sympa::Process appeared on Sympa 6.2.12 and began to
provide OO interface.
Sympa 6.2.13 introduced daemonize() method and {detached}
attribute.
As of Sympa 6.2.14, "SIGCHLD"
signal was captured and child processes were reaped immediately.
reap_child() method (formerly reaper()) was deprecated.