Proc::PID::File Update

Mike Canzoneri

Release Engineer at Synacor




...programming with threads is treacherous. The ability of one execution stream to poke holes willy-nilly into the data space of another exposes more opportunity for disaster than you can possibly imagine. - Larry Wall, Programming Perl




Sweet!
#!/usr/bin/perl

use Proc::PID::File;

# check for PID file
die("Already Running") if Proc::PID::File->running({dir => '/tmp/'});

threads->create(\&knock_knock)->join();

unless (-f "test.pid") { print "OMG no PID file!\n"; }

sub knock_knock
{
    print "Who's there?\n";
}
# test for thread safety
Proc::PID::File->running(%args);
threads->create(sub { })->join();
sleep(2);
ok(-f "test.pid", "thread safe");
sub DESTROY {
    my $self = shift;

    if (exists($INC{'threads.pm'})){
        return if (threads->tid() != 0);
    }
...
}
In Closing...
[any material that should appear in print but not on the slide]