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

tye predicts PEBKAC

Tell your friend, "Where's your code?". Fourth-party debugging without the code involved seems likely doomed. Posting a node about this seems like it really shouldn't have been your next step.

I like fcntl-based locks better than flock, so you could ask your friend to try using those instead (just in case flock is just fundamentally broken on his copy of Perl). See fcntl, Fcntl, and File::FcntlLock.

Update: http://www.nntp.perl.org/group/perl.perl5.porters/2009/04/msg145477.html was interesting, if perhaps more tangential than on-target here.

- tye        

  • Comment on Re: Lightweight Solution To "Only 1 Process Running" On AIX (fcntl)

Replies are listed 'Best First'.
Re^2: Lightweight Solution To "Only 1 Process Running" On AIX (fcntl)
by Limbic~Region (Chancellor) on May 01, 2009 at 15:25 UTC
    tye,
    I wrote and ran code myself at your and JavaFan's prodding - shown here. I get the same error. The perl is 5.8.2 (I can provide the -V if desired but I doubt it). I will look into File::FcntLock but I was hoping to avoid having to compile anything since that is a long process in this environment.

    Cheers - L~R

      You can do fcntl-based locking in pure Perl. Now that you mention that File::FcntlLock has an XS component, I bet it only does that to avoid what might seem somewhat hackish use of pack. I suspect google can pretty quickly find you examples of how to do this is plain Perl (or just follow the documentation -- it isn't rocket surgery).

      - tye        

        File::FcntlLock is an XS module precisely for that reason. Using pack isn't that easy as you make it look: you need to know the exact layout of the flock structure used on the system, and this differs considerably between system (different numbers of members, different ordering of the members, different types of members, structure padding). Thus a program creating a flock structure using pack (or diassembling it with unpack) is, unfortunately, not portable.