/[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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 134 - (hide annotations)
Wed Oct 7 17:47:50 2009 UTC (14 years, 9 months ago) by dpavlin
File size: 418 byte(s)
sane pid messages
1 dpavlin 127 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 dpavlin 133 if ( $old_pid == $pid ) {
17 dpavlin 134 warn "[$port] reusing pid $pid\n";
18 dpavlin 133 } else {
19     warn "[$port] kill old $old_pid from $pid\n";
20     kill 9, $old_pid;
21     }
22 dpavlin 127 }
23     write_file $pid_path, $pid;
24    
25     }
26    
27     1;

  ViewVC Help
Powered by ViewVC 1.1.26