Skip Menu |

This queue is for tickets about the Proc-PID-File CPAN distribution.

Report information
The Basics
Id: 50078
Status: open
Priority: 0/
Queue: Proc-PID-File

People
Owner: Nobody in particular
Requestors: jdhedden [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.25
Fixed in: (no value)



Subject: [PATCH] Add support for Cygwin
The attached patch adds support for the Cygwin platform.
Subject: patch.txt
diff -urN Proc-PID-File-1.25.orig/File.pm Proc-PID-File-1.25/File.pm --- Proc-PID-File-1.25.orig/File.pm 2009-09-26 21:50:51.000000000 -0400 +++ Proc-PID-File-1.25/File.pm 2009-09-28 16:43:32.221628400 -0400 @@ -75,11 +75,17 @@ =item I<verify> = 1 | string -This parameter helps prevent the problem described in the WARNING section below. If set to a string, it will be interpreted as a I<regular expression> and used to search within the name of the running process. A 1 may also be passed, indicating that the value of I<$0> should be used (stripped of its full path). If the parameter is not passed, no verification will take place. +This parameter helps prevent the problem described in the WARNING section +below. If set to a string, it will be interpreted as a I<regular expression> +and used to search within the name of the running process. A 1 may also be +passed: For Linux and FreeBSD, this indicates that the value of I<$0> should +be used (stripped of its full path), and for Cygwin, I<$^X> (stripped of its +full path and extension). If the parameter is not passed, no verification +will take place. Please note that verification will only work for the operating systems listed below and that the os will be auto-sensed. See also DEPENDENCIES section below. -Supported platforms: Linux, FreeBSD +Supported platforms: Linux, FreeBSD, Cygwin =item I<debug> @@ -121,13 +127,18 @@ my ($self, $pid) = @_; return 1 unless $self->{verify}; - eval "use Config"; - die "$@\nCannot use the Config module. Please install.\n" if $@; - - $self->debug("verifying on: $Config::Config{osname}"); - if ($Config::Config{osname} =~ /linux|freebsd/i) { + $self->debug("verifying on: $^O"); + if ($^O =~ /linux|freebsd|cygwin/i) { my $me = $self->{verify}; - ($me = $0) =~ s|.*/|| if !$me || $me eq "1"; + if (!$me || $me eq "1") { + if ($^O eq 'cygwin') { + $^X =~ m|([^/]+)$|; + $me = $1; + $me =~ s/\.exe$//; + } else { + $me = $ME; + } + } my @ps = split m|$/|, qx/ps -fp $pid/ || die "ps utility not available: $!"; s/^\s+// for @ps; # leading spaces confuse us @@ -207,7 +218,10 @@ =head1 DEPENDENCIES -For Linux and FreeBSD, support of the I<verify> option (simple interface) requires the B<ps> utility to be available. This is typically found in the B<procps> RPM. +For Linux, FreeBSD and Cygwin, support of the I<verify> option (simple +interface) requires the B<ps> utility to be available. For Linux and FreeBSD, +this is typically found in the B<procps> RPM. For Cygwin, you must be using +version 1.5.20 or later for this to work. =head1 WARNING diff -urN Proc-PID-File-1.25.orig/test.pl Proc-PID-File-1.25/test.pl --- Proc-PID-File-1.25.orig/test.pl 2009-09-26 21:13:27.000000000 -0400 +++ Proc-PID-File-1.25/test.pl 2009-09-28 16:43:47.771189900 -0400 @@ -61,8 +61,12 @@ my $rc = Proc::PID::File->running(%args); ok($rc, "running"); -$rc = Proc::PID::File->running(%args, verify => 1); -ok($rc, "verified: real"); +SKIP: { + skip('Verify not supported on this platform', 1) + if ($^O !~ /linux|freebsd|cygwin/i); + $rc = Proc::PID::File->running(%args, verify => 1); + ok($rc, "verified: real"); +} # WARNING: the following test takes over the pidfile from the # daemon such that he cannot clean it up. this is as it should be
CC: Mike Canzoneri <mikecanzoneri [...] gmail.com>
Subject: Re: [rt.cpan.org #50078] [PATCH] Add support for Cygwin
Date: Wed, 30 Sep 2009 14:32:30 -0700
To: bug-Proc-PID-File [...] rt.cpan.org
From: Erick Calder <e [...] arix.com>
implemented in revision 2469. tests had to be implemented differently as the skip() function doesn't seem to exist. tested the skips by setting $^O = "jacked". thanks Jerry for $^O - much better than the $Config thing! On Sep 28, 2009, at 1:44 PM, Jerry D. Hedden via RT wrote: Show quoted text
> Mon Sep 28 16:44:26 2009: Request 50078 was acted upon. > Transaction: Ticket created by JDHEDDEN > Queue: Proc-PID-File > Subject: [PATCH] Add support for Cygwin > Broken in: 1.25 > Severity: Important > Owner: Nobody > Requestors: jdhedden@cpan.org > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=50078 > > > > The attached patch adds support for the Cygwin platform. > diff -urN Proc-PID-File-1.25.orig/File.pm Proc-PID-File-1.25/File.pm > --- Proc-PID-File-1.25.orig/File.pm 2009-09-26 21:50:51.000000000 > -0400 > +++ Proc-PID-File-1.25/File.pm 2009-09-28 16:43:32.221628400 -0400 > @@ -75,11 +75,17 @@ > > =item I<verify> = 1 | string > > -This parameter helps prevent the problem described in the WARNING > section below. If set to a string, it will be interpreted as a > I<regular expression> and used to search within the name of the > running process. A 1 may also be passed, indicating that the value > of I<$0> should be used (stripped of its full path). If the > parameter is not passed, no verification will take place. > +This parameter helps prevent the problem described in the WARNING > section > +below. If set to a string, it will be interpreted as a I<regular
> expression>
> +and used to search within the name of the running process. A 1 may > also be > +passed: For Linux and FreeBSD, this indicates that the value of I< > $0> should > +be used (stripped of its full path), and for Cygwin, I<$^X> > (stripped of its > +full path and extension). If the parameter is not passed, no > verification > +will take place. > > Please note that verification will only work for the operating > systems listed below and that the os will be auto-sensed. See also > DEPENDENCIES section below. > > -Supported platforms: Linux, FreeBSD > +Supported platforms: Linux, FreeBSD, Cygwin > > =item I<debug> > > @@ -121,13 +127,18 @@ > my ($self, $pid) = @_; > return 1 unless $self->{verify}; > > - eval "use Config"; > - die "$@\nCannot use the Config module. Please install.\n" if $@; > - > - $self->debug("verifying on: $Config::Config{osname}"); > - if ($Config::Config{osname} =~ /linux|freebsd/i) { > + $self->debug("verifying on: $^O"); > + if ($^O =~ /linux|freebsd|cygwin/i) { > my $me = $self->{verify}; > - ($me = $0) =~ s|.*/|| if !$me || $me eq "1"; > + if (!$me || $me eq "1") { > + if ($^O eq 'cygwin') { > + $^X =~ m|([^/]+)$|; > + $me = $1; > + $me =~ s/\.exe$//; > + } else { > + $me = $ME; > + } > + } > my @ps = split m|$/|, qx/ps -fp $pid/ > || die "ps utility not available: $!"; > s/^\s+// for @ps; # leading spaces confuse us > @@ -207,7 +218,10 @@ > > =head1 DEPENDENCIES > > -For Linux and FreeBSD, support of the I<verify> option (simple > interface) requires the B<ps> utility to be available. This is > typically found in the B<procps> RPM. > +For Linux, FreeBSD and Cygwin, support of the I<verify> option > (simple > +interface) requires the B<ps> utility to be available. For Linux > and FreeBSD, > +this is typically found in the B<procps> RPM. For Cygwin, you must > be using > +version 1.5.20 or later for this to work. > > =head1 WARNING > > diff -urN Proc-PID-File-1.25.orig/test.pl Proc-PID-File-1.25/test.pl > --- Proc-PID-File-1.25.orig/test.pl 2009-09-26 21:13:27.000000000 > -0400 > +++ Proc-PID-File-1.25/test.pl 2009-09-28 16:43:47.771189900 -0400 > @@ -61,8 +61,12 @@ > my $rc = Proc::PID::File->running(%args); > ok($rc, "running"); > > -$rc = Proc::PID::File->running(%args, verify => 1); > -ok($rc, "verified: real"); > +SKIP: { > + skip('Verify not supported on this platform', 1) > + if ($^O !~ /linux|freebsd|cygwin/i); > + $rc = Proc::PID::File->running(%args, verify => 1); > + ok($rc, "verified: real"); > +} > > # WARNING: the following test takes over the pidfile from the > # daemon such that he cannot clean it up. this is as it should be