Reputation: 19
when I was trying to use flock in AIX box I was getting flock not found. System admin has installed util-linux package but he said flock executable is not available in AIX. Please let me know how to get flock command in AIX??
Upvotes: 2
Views: 999
Reputation: 1910
You can compile flock.c
from package util-linux
, but it won't have the whole functionality of the linux version:
flock -n <handle>
doesn't work, because on AIX, child and parent processes don't share file-locks.
With option -w <timeout>
it will wait forever (if timeout is non-zero), as flock(2)
on AIX doesn't return with errno=EINTR when a timer fires (SIGALRM).
Here's an example that does work on AIX:
#!/bin/sh
if [ "x$1" = x-locked ]; then
shift
else
echo "Trying flock on 'flock.tmp'"
if ! flock --verbose -w 0 flock.tmp "$0" -locked "$@"; then
echo 'Flock failed'
fi
exit
fi
echo "After flock -- sleeping 15 sec"
sleep 15
echo "Exiting"
Here is the flock version I compiled from source: http://web.axelero.hu/lzsiga/flock.tgz
Upvotes: 2
Reputation: 2349
This package I think has the flock command. http://www.perzl.org/aix/index.php?n=Main.Util-linux
Upvotes: -2