Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Lightweight Solution To "Only 1 Process Running" On AIX

by hossman (Prior)
on May 01, 2009 at 23:10 UTC ( #761430=note: print w/ replies, xml ) Need Help??


in reply to Lightweight Solution To "Only 1 Process Running" On AIX

It's been 11 years since I've used an AIX machine, but if i remember correctly binding a socket to a specific port works on AIX (and every other OS i've ever tried)...

#!/usr/bin/perl -l use warnings; use strict; use Socket; my $sock_fh; BEGIN { my $port = 987654; # any constant specific to this app socket($sock_fh, PF_INET, SOCK_STREAM, getprotobyname('tcp')) or die "socket: $!"; bind($sock_fh, sockaddr_in($port, INADDR_LOOPBACK)) or (warn "another process is already running ($!)\n" and exit(1)); } # BEGIN: where you do your work print "send interupt to kill process"; while (<>) { sleep 1; } # END: where you do your work END { $sock_fh->close() if defined $sock_fh; }


Comment on Re: Lightweight Solution To "Only 1 Process Running" On AIX
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://761430]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2014-09-20 10:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (158 votes), past polls