r67493 - in /branches/upstream/libproc-daemon-perl/current: Changes MANIFEST META.yml README lib/Proc/Daemon.pm lib/Proc/Daemon.pod
periapt-guest at users.alioth.debian.org
periapt-guest at users.alioth.debian.org
Tue Jan 18 21:21:01 UTC 2011
Author: periapt-guest
Date: Tue Jan 18 21:20:54 2011
New Revision: 67493
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=67493
Log:
[svn-upgrade] new version libproc-daemon-perl (0.06)
Modified:
branches/upstream/libproc-daemon-perl/current/Changes
branches/upstream/libproc-daemon-perl/current/MANIFEST
branches/upstream/libproc-daemon-perl/current/META.yml
branches/upstream/libproc-daemon-perl/current/README
branches/upstream/libproc-daemon-perl/current/lib/Proc/Daemon.pm
branches/upstream/libproc-daemon-perl/current/lib/Proc/Daemon.pod
Modified: branches/upstream/libproc-daemon-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libproc-daemon-perl/current/Changes?rev=67493&op=diff
==============================================================================
--- branches/upstream/libproc-daemon-perl/current/Changes (original)
+++ branches/upstream/libproc-daemon-perl/current/Changes Tue Jan 18 21:20:54 2011
@@ -1,33 +1,41 @@
-Revision history for Perl module Proc::Daemon.
-
-0.05 Thu Okt 28 2010
- - fixed a problem when using the old method of calling Proc::Daemon::Init
- without object (reported by Alex Samorukov). The parent process didn't
- exit.
- - fixed a problem with Proc::ProcessTable 0.44: Under some conditions
- 'cmndline' retruns with space and/or other characters at the end.
- - Update and small fixes in the documentation.
-
-0.04 Sun Okt 24 2010
- - Added functions: new(), adjust_settings(), fix_filename(), Status(),
- Kill_Daemon(), get_pid() and get_pid_by_proc_table_attr().
- - Init() now returns the PID of the daemon.
- - Fork() now allways returns values like Perls built-in 'fork' does.
- - Description was rewritten, extended and moved to the new Daemon.pod file.
- - Additional test are done at installation.
- - $SIG{'HUP'} was set to be valid only 'local' (bug report).
- - POSIX::EAGAIN() was added to Fork() (bug report).
-
-0.03 Thu Jun 19 2003
- - Licensing is more explicit: Either GPL or Artistic.
- - Updated author contact information.
-
-0.02 Sat Apr 17 1999
- - init() function superceded by Init() function.
- - All open files are closed during daemonization.
- - A double fork is now down to avoid the potential of acquiring
- a controlling terminal.
- - Added Fork() and OpenMax() functions.
-
-0.01 Thu Jan 27 1998
- - initial bundled release.
+Revision history for Perl module Proc::Daemon.
+
+0.06 Mon Jan 17 2011
+ - A lot of documentation was add to the source code.
+ - Daemon STDIN was fixed to "read" now instead of "write".
+ - Replaced global filehandles with scalars.
+ - Add a <die> if <chdir> fails.
+ - Updated the documentation and add a note to the documentation about the
+ behavior of process-group Signals.
+
+0.05 Thu Okt 28 2010
+ - fixed a problem when using the old method of calling Proc::Daemon::Init
+ without object (reported by Alex Samorukov). The parent process didn't
+ exit.
+ - fixed a problem with Proc::ProcessTable 0.44: Under some conditions
+ 'cmndline' retruns with space and/or other characters at the end.
+ - Update and small fixes in the documentation.
+
+0.04 Sun Okt 24 2010
+ - Added functions: new(), adjust_settings(), fix_filename(), Status(),
+ Kill_Daemon(), get_pid() and get_pid_by_proc_table_attr().
+ - Init() now returns the PID of the daemon.
+ - Fork() now allways returns values like Perls built-in 'fork' does.
+ - Description was rewritten, extended and moved to the new Daemon.pod file.
+ - Additional test are done at installation.
+ - $SIG{'HUP'} was set to be valid only 'local' (bug report).
+ - POSIX::EAGAIN() was added to Fork() (bug report).
+
+0.03 Thu Jun 19 2003
+ - Licensing is more explicit: Either GPL or Artistic.
+ - Updated author contact information.
+
+0.02 Sat Apr 17 1999
+ - init() function superceded by Init() function.
+ - All open files are closed during daemonization.
+ - A double fork is now down to avoid the potential of acquiring
+ a controlling terminal.
+ - Added Fork() and OpenMax() functions.
+
+0.01 Thu Jan 27 1998
+ - initial bundled release.
Modified: branches/upstream/libproc-daemon-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libproc-daemon-perl/current/MANIFEST?rev=67493&op=diff
==============================================================================
--- branches/upstream/libproc-daemon-perl/current/MANIFEST (original)
+++ branches/upstream/libproc-daemon-perl/current/MANIFEST Tue Jan 18 21:20:54 2011
@@ -1,9 +1,9 @@
-Changes
-MANIFEST
-Makefile.PL
-README
-lib/Proc/Daemon.pm
-lib/Proc/Daemon.pod
-t/01_loadmodule.t
-t/02_testmodule.t
-META.yml Module meta-data (added by MakeMaker)
+Changes
+MANIFEST
+Makefile.PL
+README
+lib/Proc/Daemon.pm
+lib/Proc/Daemon.pod
+t/01_loadmodule.t
+t/02_testmodule.t
+META.yml Module meta-data (added by MakeMaker)
Modified: branches/upstream/libproc-daemon-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libproc-daemon-perl/current/META.yml?rev=67493&op=diff
==============================================================================
--- branches/upstream/libproc-daemon-perl/current/META.yml (original)
+++ branches/upstream/libproc-daemon-perl/current/META.yml Tue Jan 18 21:20:54 2011
@@ -1,22 +1,14 @@
--- #YAML:1.0
-name: Proc-Daemon
-version: 0.05
-abstract: ~
-author:
+name: Proc-Daemon
+version: 0.06
+abstract: ~
+license: perl
+author:
- Earl Hood earl at earlhood.com, Detlef Pilzecker deti at cpan.org
-license: perl
-distribution_type: module
-configure_requires:
- ExtUtils::MakeMaker: 0
-build_requires:
- ExtUtils::MakeMaker: 0
-requires:
- POSIX: 0
-no_index:
- directory:
- - t
- - inc
-generated_by: ExtUtils::MakeMaker version 6.56
+generated_by: ExtUtils::MakeMaker version 6.42
+distribution_type: module
+requires:
+ POSIX: 0
meta-spec:
- url: http://module-build.sourceforge.net/META-spec-v1.4.html
- version: 1.4
+ url: http://module-build.sourceforge.net/META-spec-v1.3.html
+ version: 1.3
Modified: branches/upstream/libproc-daemon-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libproc-daemon-perl/current/README?rev=67493&op=diff
==============================================================================
--- branches/upstream/libproc-daemon-perl/current/README (original)
+++ branches/upstream/libproc-daemon-perl/current/README Tue Jan 18 21:20:54 2011
@@ -1,55 +1,55 @@
-README for Proc::Daemon
-
----------------------------------------------------------------------------
-SUMMARY
-
-Proc::Daemon provides the capability for a Perl program to run
-as a Unix daemon process.
-
----------------------------------------------------------------------------
-INSTALLATION
-
-This module can be installed on Perl 5.8.
-It was not tested on older versions but it might work.
-
-You should be able to install the module with the following:
-
- perl Makefile.PL
- make
- make test
- make install
-
-If you want to install in a specific directory, try:
-
- perl Makefile.PL PREFIX=/tmp/myperl5
- ...
-
-If you'd like to see the raw output of the tests, try:
-
- ...
- make test TEST_VERBOSE=1
- ...
-
----------------------------------------------------------------------------
-DOCUMENTATION
-
-Documentation is in the Daemon.pod file and should automatically get installed
-with the module.
-
----------------------------------------------------------------------------
-COPYRIGHT (C) 1997-2010
-
-Earl Hood
-earl at earlhood.com
-http://www.earlhood.com/
-
-and
-
-Detlef Pilzecker
-deti at cpan.org
-http://www.secure-sip-server.net/
-
-All rights reserved.
-
-This module is free software. It may be used, redistributed and/or modified
-under the same terms as Perl itself.
+README for Proc::Daemon
+
+---------------------------------------------------------------------------
+SUMMARY
+
+Proc::Daemon provides the capability for a Perl program to run
+as a Unix daemon process.
+
+---------------------------------------------------------------------------
+INSTALLATION
+
+This module can be installed on Perl 5.8.
+It was not tested on older versions but it might work.
+
+You should be able to install the module with the following:
+
+ perl Makefile.PL
+ make
+ make test
+ make install
+
+If you want to install in a specific directory, try:
+
+ perl Makefile.PL PREFIX=/tmp/myperl5
+ ...
+
+If you'd like to see the raw output of the tests, try:
+
+ ...
+ make test TEST_VERBOSE=1
+ ...
+
+---------------------------------------------------------------------------
+DOCUMENTATION
+
+Documentation is in the Daemon.pod file and should automatically get installed
+with the module.
+
+---------------------------------------------------------------------------
+COPYRIGHT (C) 1997-2011
+
+Earl Hood
+earl at earlhood.com
+http://www.earlhood.com/
+
+and
+
+Detlef Pilzecker
+deti at cpan.org
+http://www.secure-sip-server.net/
+
+All rights reserved.
+
+This module is free software. It may be used, redistributed and/or modified
+under the same terms as Perl itself.
Modified: branches/upstream/libproc-daemon-perl/current/lib/Proc/Daemon.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libproc-daemon-perl/current/lib/Proc/Daemon.pm?rev=67493&op=diff
==============================================================================
--- branches/upstream/libproc-daemon-perl/current/lib/Proc/Daemon.pm (original)
+++ branches/upstream/libproc-daemon-perl/current/lib/Proc/Daemon.pm Tue Jan 18 21:20:54 2011
@@ -7,7 +7,7 @@
## Description:
## see Daemon.pod file
################################################################################
-## Copyright (C) 1997-2010 by Earl Hood and Detlef Pilzecker.
+## Copyright (C) 1997-2011 by Earl Hood and Detlef Pilzecker.
##
## All rights reserved.
##
@@ -21,7 +21,7 @@
use strict;
use POSIX();
-$Proc::Daemon::VERSION = '0.05';
+$Proc::Daemon::VERSION = '0.06';
################################################################################
@@ -31,8 +31,8 @@
# %Daemon_Settings are hash key=>values and can be:
# work_dir => '/working/daemon/directory' -> defaults to '/'
# child_STDIN => '/path/to/daemon/STDIN.file' -> defautls to '/dev/null'
-# child_STDOUT => '/path/to/daemon/STDOUT.file' -> defaults to *\STDIN
-# child_STDERR => '/path/to/daemon/STDERR.file' -> defaults to *\STDIN
+# child_STDOUT => '/path/to/daemon/STDOUT.file' -> defaults to '/dev/null'
+# child_STDERR => '/path/to/daemon/STDERR.file' -> defaults to '/dev/null'
# pid_file => '/path/to/pid/file.txt' -> defaults to
# undef (= write no file)
# exec_command => 'perl /home/script.pl' -> execute a system command
@@ -69,7 +69,8 @@
# Returns to the parent:
# - nothing (parent does exit) if the context is looking for no return value.
# - the PID(s) of the daemon(s) created.
-# Returns to the child : 0 | never returns if used with 'exec_command'.
+# Returns to the child (daemon):
+# its PID (= 0) | never returns if used with 'exec_command'.
################################################################################
sub Init {
my Proc::Daemon $self = shift;
@@ -88,56 +89,105 @@
# Open a filehandle to the anonymous temporary pid file.
- open( MEMORY, "+>", undef ) || die "Can not open anonymous temporary pidfile: $!";
+ open( my $FH_MEMORY, "+>", undef ) || die "Can not open anonymous temporary pidfile: $!";
# If system commands are to be executed, put them in a list.
my @exec_command = ref( $self->{exec_command} ) eq 'ARRAY' ? @{ $self->{exec_command} } : ( $self->{exec_command} );
$#exec_command = 0 if $#exec_command < 0;
- # Run a daemon once or for every system command.
+ # Create a daemon for every system command.
foreach my $exec_command ( @exec_command ) {
- # First parent is running here.
-
-
- # Using this subroutine or loop multiple times we must modify the files:
+ # The first parent is running here.
+
+
+ # Using this subroutine or loop multiple times we must modify the filenames:
# 'child_STDIN', 'child_STDOUT', 'child_STDERR' and 'pid_file' for every
- # daemon. A highter number will be appended to the files.
+ # daemon (a higher number will be appended to the filenames).
$self->adjust_settings();
# First fork.
my $pid = Fork();
- unless ( $pid || ! defined $pid ) {
- # First child runs here.
-
-
- # Detach ourselves from the terminal.
+ if ( defined $pid && $pid == 0 ) {
+ # The first child runs here.
+
+
+ # Set the new working directory.
+ chdir $self->{work_dir} or die "Can't <chdir> to $self->{work_dir}: $!";
+
+ # Clear the file creation mask.
+ umask 0;
+
+ # Detach the child from the terminal (no controlling tty), make it the
+ # session-leader and the process-group-leader of a new process group.
die "Cannot detach from controlling terminal" if POSIX::setsid() < 0;
- # Prevent possibility of acquiring a controling terminal.
- local $SIG{'HUP'} = 'IGNORE';
+ # "Is ignoring SIGHUP necessary?
+ #
+ # It's often suggested that the SIGHUP signal should be ignored before
+ # the second fork to avoid premature termination of the process. The
+ # reason is that when the first child terminates, all processes, e.g.
+ # the second child, in the orphaned group will be sent a SIGHUP.
+ #
+ # 'However, as part of the session management system, there are exactly
+ # two cases where SIGHUP is sent on the death of a process:
+ #
+ # 1) When the process that dies is the session leader of a session that
+ # is attached to a terminal device, SIGHUP is sent to all processes
+ # in the foreground process group of that terminal device.
+ # 2) When the death of a process causes a process group to become
+ # orphaned, and one or more processes in the orphaned group are
+ # stopped, then SIGHUP and SIGCONT are sent to all members of the
+ # orphaned group.' [2]
+ #
+ # The first case can be ignored since the child is guaranteed not to have
+ # a controlling terminal. The second case isn't so easy to dismiss.
+ # The process group is orphaned when the first child terminates and
+ # POSIX.1 requires that every STOPPED process in an orphaned process
+ # group be sent a SIGHUP signal followed by a SIGCONT signal. Since the
+ # second child is not STOPPED though, we can safely forego ignoring the
+ # SIGHUP signal. In any case, there are no ill-effects if it is ignored."
+ # Source: http://code.activestate.com/recipes/278731/
+ #
+ # local $SIG{'HUP'} = 'IGNORE';
# Second fork.
+ # This second fork is not absolutely necessary, it is more a precaution.
+ # 1. Prevent possibility of reacquiring a controlling terminal.
+ # Without this fork the daemon would remain a session-leader. In
+ # this case there is a potential possibility that the process could
+ # reacquire a controlling terminal. E.g. if it opens a terminal device,
+ # without using the O_NOCTTY flag. In Perl this is normally the case
+ # when you use <open> on this kind of device, instead of <sysopen>
+ # with the O_NOCTTY flag set.
+ # Note: Because of the second fork the daemon will not be a session-
+ # leader and therefore Signals will not be send to other members of
+ # his process group. If you need the functionality of a session-leader
+ # you may want to call POSIX::setsid() manually on your daemon.
+ # 2. Detach the daemon completely from the parent.
+ # The double-fork prevents the daemon from becoming a zombie. It is
+ # needed in this module because the grandparent process can continue.
+ # Without the second fork and if a child exits before the parent
+ # and you forget to call <wait> in the parent you will get a zombie
+ # until the parent also terminates. Using the second fork we can be
+ # sure that the parent of the daemon is finished near by or before
+ # the daemon exits.
$pid = Fork();
- unless ( $pid || ! defined $pid ) {
- # Here is the second child running.
-
-
- # Set the new working directory.
- chdir $self->{work_dir};
-
- # Clear file creation mask.
- umask 0;
+ if ( defined $pid && $pid == 0 ) {
+ # Here the second child is running.
+
# Close open file handles/descriptors.
- # MEMORY also will be closed here.
+ # $FH_MEMORY also will be closed here.
foreach ( 0 .. OpenMax() ) { POSIX::close( $_ ) }
- # Reopen STDIN, STDOUT and STDERR to '..._path' or write to /dev/null
- open ( STDIN, ( $self->{child_STDIN} ? "+>$self->{child_STDIN}" : "+>/dev/null" ) );
- open ( STDOUT, ( $self->{child_STDOUT} ? "+>$self->{child_STDOUT}" : "+>&STDIN" ) );
- open ( STDERR, ( $self->{child_STDERR} ? "+>$self->{child_STDERR}" : "+>&STDIN" ) );
+ # Reopen STDIN, STDOUT and STDERR to '..._path' or to /dev/null.
+ # Data written on a null special file is discarded. Reads from
+ # the null special file always return end of file.
+ open( STDIN, "<", $self->{child_STDIN} || "/dev/null" );
+ open( STDOUT, "+>", $self->{child_STDOUT} || "/dev/null" );
+ open( STDERR, "+>", $self->{child_STDERR} || "/dev/null" );
# Execute a system command and never return.
@@ -150,27 +200,33 @@
}
- # Return the childs own PID (0)
+ # Return the childs own PID (= 0)
return $pid;
}
# First child (= second parent) runs here.
+
# Print the PID of the second child into ...
# ... the anonymous temporary pid file.
$pid ||= '';
- print MEMORY "$pid\n";
- close MEMORY;
+ print $FH_MEMORY "$pid\n";
+ close $FH_MEMORY;
# ... the real 'pid_file'.
if ( $self->{pid_file} ) {
- open( PIDFILE, "+>", $self->{pid_file} ) || die "Can not open pidfile (pid_file => '$self->{pid_file}'): $!";
- print PIDFILE $pid;
- close PIDFILE;
+ open( my $FH_PIDFILE, "+>", $self->{pid_file} ) ||
+ die "Can not open pidfile (pid_file => '$self->{pid_file}'): $!";
+ print $FH_PIDFILE $pid;
+ close $FH_PIDFILE;
}
- # Don't 'wait' for the second child to exit,
- # even if we don't have a value in $exec_command
+
+ # Don't <wait> for the second child to exit,
+ # even if we don't have a value in $exec_command.
+ # The second child will become orphan by <exit> here, but then it
+ # will be adopted by init(8), which automatically performs a <wait>
+ # to remove the zombie when the child exits.
exit;
}
@@ -179,18 +235,19 @@
# Only first parent runs here.
- # Wait for the first child to exit!!
- wait;
+ # A child that terminates, but has not been waited for becomes
+ # a zombie. So we wait for the first child to exit.
+ waitpid( $pid, 0 );
}
# Only first parent runs here.
- # Get the second child/ren PIDs out of the anonymous temporary pid file.
- seek( MEMORY, 0, 0 );
- my @pid = map { chomp $_; $_ eq '' ? undef : $_ } <MEMORY>;
- close MEMORY;
+ # Get the daemon PIDs out of the anonymous temporary pid file.
+ seek( $FH_MEMORY, 0, 0 );
+ my @pid = map { chomp $_; $_ eq '' ? undef : $_ } <$FH_MEMORY>;
+ close $FH_MEMORY;
# Exit if the context is looking for no value (void context).
@@ -377,9 +434,9 @@
if ( $killed && $pidfile ) {
# Set PID in pid file to '0'.
- if ( open( PIDFILE, "+>", $pidfile ) ) {
- print PIDFILE '0';
- close PIDFILE;
+ if ( open( my $FH_PIDFILE, "+>", $pidfile ) ) {
+ print $FH_PIDFILE '0';
+ close $FH_PIDFILE;
}
else { warn "Can not open pidfile (pid_file => '$pidfile'): $!" }
}
@@ -412,9 +469,9 @@
$pid = $string;
}
# Open the pidfile and get the PID from it.
- elsif ( open( MEMORY, "<", $string ) ) {
- $pid = <MEMORY>;
- close MEMORY;
+ elsif ( open( my $FH_MEMORY, "<", $string ) ) {
+ $pid = <$FH_MEMORY>;
+ close $FH_MEMORY;
die "I found no valid PID ('$pid') in the pidfile: '$string'" if $pid =~ /\D/s;
@@ -430,9 +487,9 @@
# Try to get the PID out of the new() settings.
if ( ! $pid ) {
# Try to get the PID out of the 'pid_file' setting.
- if ( $self->{pid_file} && open( MEMORY, "<", $self->{pid_file} ) ) {
- $pid = <MEMORY>;
- close MEMORY;
+ if ( $self->{pid_file} && open( my $FH_MEMORY, "<", $self->{pid_file} ) ) {
+ $pid = <$FH_MEMORY>;
+ close $FH_MEMORY;
if ( ! $pid || ( $pid && $pid =~ /\D/s ) ) { $pid = undef }
else { $pidfile = $self->{pid_file} }
Modified: branches/upstream/libproc-daemon-perl/current/lib/Proc/Daemon.pod
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libproc-daemon-perl/current/lib/Proc/Daemon.pod?rev=67493&op=diff
==============================================================================
--- branches/upstream/libproc-daemon-perl/current/lib/Proc/Daemon.pod (original)
+++ branches/upstream/libproc-daemon-perl/current/lib/Proc/Daemon.pod Tue Jan 18 21:20:54 2011
@@ -1,7 +1,7 @@
=head1 NAME
-Proc::Daemon - Run Perl program(s) as a daemon process
+Proc::Daemon - Run Perl program(s) as a daemon process.
@@ -15,16 +15,16 @@
.....
);
- $Kid_PID = $daemon->Init;
-
- unless ( $Kid_PID ) {
+ $Kid_1_PID = $daemon->Init;
+
+ unless ( $Kid_1_PID ) {
# code executed only by the child ...
}
- $Kid_PID2 = $daemon->Init( {
+ $Kid_2_PID = $daemon->Init( {
work_dir => '/other/daemon/directory',
exec_command => 'perl /home/my_script.pl',
- } );
+ } );
$pid = $daemon->Status( ... );
@@ -55,25 +55,26 @@
=item 2
-The forked child becomes a session leader, which detaches the program from the
+The child changes the current working directory to
+the value of 'work_dir'.
+
+
+=item 3
+
+The child clears the file creation mask.
+
+
+=item 4
+
+The child becomes a session leader, which detaches the program from the
controlling terminal.
-=item 3
-
-This child forks another child (the final daemon process). This prevents
-the potential of acquiring a controlling terminal at all.
-
-
-=item 4
-
-The second child changes the current working directory to
-the value of 'work_dir'.
-
-
=item 5
-The second child clears the file creation mask.
+The child forks another child (the final daemon process). This prevents
+the potential of acquiring a controlling terminal at all and detaches the
+daemon completely from the first parent.
=item 6
@@ -89,8 +90,8 @@
=item 8
-The second child returns to the first process (grandparent), or the program
-defined in 'exec_command' is executed and the second child never returns.
+The second child returns to the calling script, or the program defined
+in 'exec_command' is executed and the second child never returns.
=item 9
@@ -102,6 +103,12 @@
=back
+NOTE: Because of the second fork the daemon will not be a session-leader and
+therefore Signals will not be send to other members of his process group. If
+you need the functionality of a session-leader you may want to call
+POSIX::setsid() manually on your daemon.
+
+
=head1 CONSTRUCTOR
@@ -124,18 +131,20 @@
=item child_STDIN
-Defines the path to STDIN of your daemon. Defaults to C</dev/null>.
+Defines the path to STDIN of your daemon. Defaults to C</dev/null>. Mode is '<'
+(read).
=item child_STDOUT
-Defines the path where the output of your daemon will go. Defaults to C<*\STDIN>.
+Defines the path where the output of your daemon will go. Defaults to
+C</dev/null>. Mode is '+>' (write/read).
=item child_STDERR
-Defines the path where the error output of your daemon will go. Defaults
-to C<*\STDIN>.
+Defines the path where the error output of your daemon will go. Defaults to
+C</dev/null>. Mode is '+>' (write/read).
=item pid_file
@@ -146,7 +155,7 @@
=item exec_command
-Scalar (or arrayref) with system command(s) that will be executed by the
+Scalar or arrayref with system command(s) that will be executed by the
daemon via Perls C<exec PROGRAM_LIST>. In this case the child will never
return to the parents process!
@@ -161,7 +170,7 @@
child_STDERR => 'debug.txt',
pid_file => 'pid.txt',
exec_command => 'perl /home/my_script.pl',
- # or
+ # or:
# exec_command => [ 'perl /home/my_script.pl', 'perl /home/my_other_script.pl' ],
);
@@ -171,7 +180,7 @@
=item *
-the PID of the daemon will be returned into C<$daemon> of the parent process
+the PID of the daemon will be returned to C<$daemon> in the parent process
and a pid-file will be created at C</working/daemon/directory/pid.txt>
=item *
@@ -205,8 +214,8 @@
$pid = $daemon->Init();
If you want to use the object reference created by C<new> for other daemons,
-you write C<Init( { %ARGS } )>. The argument must be a hashref. %ARGS are
-the same as described in C<new>. Notice that you shouldn't call C<Init()>, or
+you write C<Init( { %ARGS } )>. %ARGS are the same as described in
+C<new>. Notice that you shouldn't call C<Init()>, or
this next daemon will do and write all in the same files as the first daemon. At
least use an empty anonymous hash.
@@ -221,6 +230,12 @@
$pid = Proc::Daemon::Init( [ { %ARGS } ] );
+To the parent C<Init> returns the PID (scalar) of the daemon, or the PIDs
+(array) of the daemons created (if C<exec_command> has more then one program
+to execute). See examples above.
+
+Returns 0 to the child (daemon).
+
If you call the C<Init> method in the context without looking for a return value
(void context) the parent process will C<exit> here like in earlier versions:
@@ -260,8 +275,8 @@
=item Kill_Daemon( [ $ARG ] )
This function kills the Daemon process. Returns the number of processes
-successfully killed (which mostly is not the same as the PID number), or
-0 if the process wasn't found.
+successfully killed (which mostly is not the same as the PID number), or 0 if
+the process wasn't found.
$ARG is the same as of C<Status()>.
@@ -287,8 +302,8 @@
=item OpenMax( [ $NUMBER ] )
-Returns the maximum file descriptor number. If undetermined, $NUMBER (if
-undefined: 64) will be returned.
+Returns the maximum file descriptor number. If undetermined $NUMBER will be
+returned.
=item adjust_settings
@@ -359,12 +374,12 @@
=item *
-B<Advanced Programming in the UNIX Environment>, by W. Richard Stevens.
+"Advanced Programming in the UNIX Environment" by W. Richard Stevens.
Addison-Wesley, Copyright 1992.
=item *
-B<UNIX Network Progamming>, Vol 1, by W. Richard Stevens.
+"UNIX Network Progamming", Vol 1, by W. Richard Stevens.
Prentice-Hall PTR, Copyright 1998.
=back
@@ -391,7 +406,7 @@
=head1 COPYRIGHT
-This module is Copyright (C) 1997-2010 by Earl Hood and Detlef Pilzecker.
+This module is Copyright (C) 1997-2011 by Earl Hood and Detlef Pilzecker.
All Rights Reserved.
More information about the Pkg-perl-cvs-commits
mailing list