Commit 0d3f5363 authored by Salvatore Bonaccorso's avatar Salvatore Bonaccorso

Imported Upstream version 0.18

parent f73ca1c5
Revision history for Perl extension App::Daemon.
0.18 (10/31/2012)
(ms) [rt.cpan.org #75931] Fixed previous release to actually work with
Proc::ProcessTable missing.
0.17 (10/30/2012)
(ms) [rt.cpan.org #75931] To address problems with Proc::ProcessTable
on some platforms, changed process_is_running() to use POSIX methods
only. Proc::ProcessTable is now optional and only required when
using process_running_by_name().
0.16 (10/21/2012)
(ms) [rt.cpan.org #44462] forked children now don't remove the master's
pid file anymore when they exit. Thanks to Felix Ostmann and
......
......@@ -2,12 +2,11 @@ package App::Daemon;
use strict;
use warnings;
our $VERSION = '0.16';
our $VERSION = '0.18';
use Getopt::Std;
use Pod::Usage;
use File::Basename;
use Proc::ProcessTable;
use Log::Log4perl qw(:easy);
use POSIX;
use Exporter;
......@@ -296,10 +295,13 @@ sub status {
print "No pidfile found\n";
$exit_code = LSB_NOT_RUNNING;
}
my @cmdlines = processes_running_by_name( $appname );
print "Name match: ", scalar @cmdlines, "\n";
for(@cmdlines) {
print " ", $_, "\n";
if( proc_processtable_available() ) {
my @cmdlines = processes_running_by_name( $appname );
print "Name match: ", scalar @cmdlines, "\n";
for(@cmdlines) {
print " ", $_, "\n";
}
}
return $exit_code;
......@@ -311,14 +313,21 @@ sub process_running {
###########################################
my($pid) = @_;
# kill(0,pid) doesn't work if we're checking a process running on
# different uid, so we need this.
my $t = Proc::ProcessTable->new();
my $rc = kill( 0, $pid );
foreach my $p ( @{$t->table} ){
return 1 if $p->pid() == $pid;
if( $rc ) {
# pseudo signal got delivered, process exists
return 1;
} elsif( $! == ESRCH ) {
# process doesn't exist
return 0;
} elsif( $! == EPERM ) {
# process does exist, but we don't have permission to
# send the signal
return 1;
}
# Weirdness ensued.
return 0;
}
......@@ -327,6 +336,8 @@ sub processes_running_by_name {
###########################################
my($name) = @_;
require Proc::ProcessTable;
$name = basename($name);
my @procs = ();
......@@ -425,6 +436,20 @@ sub pid_file_process_running {
return undef;
}
###########################################
sub proc_processtable_available {
###########################################
my $module = "Proc::ProcessTable";
eval "require $module;";
if( $@ ) {
return 0;
}
return 1;
}
1;
__END__
......
......@@ -38,7 +38,6 @@
"Getopt::Std" : "0",
"Log::Log4perl" : "1.0",
"Pod::Usage" : "0",
"Proc::ProcessTable" : "0",
"Sysadm::Install" : "0.37",
"Test::More" : "0"
}
......@@ -50,5 +49,5 @@
"url" : "http://github.com/mschilli/app-daemon"
}
},
"version" : "0.16"
"version" : "0.18"
}
......@@ -24,9 +24,8 @@ requires:
Getopt::Std: 0
Log::Log4perl: 1.0
Pod::Usage: 0
Proc::ProcessTable: 0
Sysadm::Install: 0.37
Test::More: 0
resources:
repository: http://github.com/mschilli/app-daemon
version: 0.16
version: 0.18
......@@ -16,7 +16,6 @@ WriteMakefile(
PREREQ_PM => {
Log::Log4perl => "1.0",
File::Pid => 0,
Proc::ProcessTable => 0,
Getopt::Std => 0,
Pod::Usage => 0,
File::Basename => 0,
......
######################################################################
App::Daemon 0.16
App::Daemon 0.18
######################################################################
NAME
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment