/[Sack]/trunk/lib/Sack/Pid.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/lib/Sack/Pid.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 133 - (show annotations)
Wed Oct 7 17:39:40 2009 UTC (14 years, 8 months ago) by dpavlin
File size: 438 byte(s)
don't kill $$

1 package Sack::Pid;
2
3 use warnings;
4 use strict;
5
6 use File::Slurp;
7
8 sub port_pid {
9 my ( $self, $port, $pid ) = @_;
10
11 $pid ||= $$;
12
13 my $pid_path = "/tmp/sack.$port.pid";
14 if ( -e $pid_path ) {
15 my $old_pid = read_file $pid_path;
16 if ( $old_pid == $pid ) {
17 warn "[$port] pid $pid\n";
18 } else {
19 warn "[$port] kill old $old_pid from $pid\n";
20 kill 9, $old_pid;
21 }
22 }
23 write_file $pid_path, $pid;
24 warn "[$port] pid $pid\n";
25
26 }
27
28 1;

  ViewVC Help
Powered by ViewVC 1.1.26