Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

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; }

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2021-10-21 20:03 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (83 votes). Check out past polls.