.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "File::Pid 3pm" .TH File::Pid 3pm "2022-06-13" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" File::Pid \- Pid File Manipulation .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use File::Pid; \& \& my $pidfile = File::Pid\->new({ \& file => \*(Aq/some/file.pid\*(Aq, \& }); \& \& $pidfile\->write; \& \& if ( my $num = $pidfile\->running ) { \& die "Already running: $num\en"; \& } \& \& $pidfile\->remove; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This software manages a pid file for you. It will create a pid file, query the process within to discover if it's still running, and remove the pid file. .SS "new" .IX Subsection "new" .Vb 1 \& my $pidfile = File::Pid\->new; \& \& my $thisfile = File::Pid\->new({ \& file => \*(Aq/var/run/daemon.pid\*(Aq, \& }); \& \& my $thisfileandpid = File::Pid\->new({ \& file => \*(Aq/var/run/daemon.pid\*(Aq, \& pid => \*(Aq145\*(Aq, \& }); .Ve .PP This constructor takes two optional parameters. .PP \&\f(CW\*(C`file\*(C'\fR \- The name of the pid file to work on. If not specified, a pid file located in \f(CW\*(C`File::Spec\->tmpdir()\*(C'\fR will be created that matches \&\f(CW\*(C`(File::Basename::basename($0))[0] . \*(Aq.pid\*(Aq\*(C'\fR. So, for example, if \&\f(CW$0\fR is \fI~/bin/sig.pl\fR, the pid file will be \fI/tmp/sig.pl.pid\fR. .PP \&\f(CW\*(C`pid\*(C'\fR \- The pid to write to a new pidfile. If not specified, \f(CW$$\fR is used when the pid file doesn't exist. When the pid file does exist, the pid inside it is used. .SS "file" .IX Subsection "file" .Vb 1 \& my $pidfile = $pidfile\->file; .Ve .PP Accessor/mutator for the filename used as the pid file. .SS "pid" .IX Subsection "pid" .Vb 1 \& my $pid = $pidfile\->pid; .Ve .PP Accessor/mutator for the pid being saved to the pid file. .SS "write" .IX Subsection "write" .Vb 1 \& my $pid = $pidfile\->write; .Ve .PP Writes the pid file to disk, inserting the pid inside the file. On success, the pid written is returned. On failure, \f(CW\*(C`undef\*(C'\fR is returned. .SS "running" .IX Subsection "running" .Vb 2 \& my $pid = $pidfile\->running; \& die "Service already running: $pid\en" if $pid; .Ve .PP Checks to see if the pricess identified in the pid file is still running. If the process is still running, the pid is returned. Otherwise \&\f(CW\*(C`undef\*(C'\fR is returned. .SS "remove" .IX Subsection "remove" .Vb 1 \& $pidfile\->remove or warn "Couldn\*(Aqt unlink pid file\en"; .Ve .PP Removes the pid file from disk. Returns true on success, false on failure. .SS "program_name" .IX Subsection "program_name" This is a utility method that allows you to determine what \&\f(CW\*(C`File::Pid\*(C'\fR thinks the program name is. Internally this is used when no pid file is specified. .SH "SEE ALSO" .IX Header "SEE ALSO" perl. .SH "AUTHOR" .IX Header "AUTHOR" Casey West, <\fIcasey@geeknest.com\fR>. .SH "COPYRIGHT" .IX Header "COPYRIGHT" .Vb 3 \& Copyright (c) 2005 Casey West. All rights reserved. \& This module is free software; you can redistribute it and/or modify it \& under the same terms as Perl itself. .Ve