diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2011-10-11 00:50:47 +0400 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2011-10-11 00:52:37 +0400 |
commit | 6b9f5599849045a1f07cc9b9aca23d7a02aa5260 (patch) | |
tree | 74178e76fc9010c674a7c4ff7579e72ac216893a | |
parent | e6092f337cdbeef3bb50a572a9c18dd9a8f02c34 (diff) |
gyp: work around sunos python flock() bug
flock(LOCK_EX) always fails with EBADF, use fcntl(F_SETLK) instead.
-rw-r--r-- | tools/gyp/pylib/gyp/sun_tool.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/tools/gyp/pylib/gyp/sun_tool.py b/tools/gyp/pylib/gyp/sun_tool.py index be666b35d05..6ccec473b8c 100644 --- a/tools/gyp/pylib/gyp/sun_tool.py +++ b/tools/gyp/pylib/gyp/sun_tool.py @@ -5,11 +5,9 @@ """These functions are executed via gyp-sun-tool when using the Makefile generator.""" -import os import fcntl -import plistlib -import shutil -import string +import os +import struct import subprocess import sys @@ -36,6 +34,14 @@ class SunTool(object): def ExecFlock(self, lockfile, *cmd_list): """Emulates the most basic behavior of Linux's flock(1).""" # Rely on exception handling to report errors. - fd = os.open(lockfile, os.O_RDONLY|os.O_NOCTTY|os.O_CREAT, 0o666) - fcntl.flock(fd, fcntl.LOCK_EX) + # Note that the stock python on SunOS has a bug + # where fcntl.flock(fd, LOCK_EX) always fails + # with EBADF, that's why we use this F_SETLK + # hack instead. + fd = os.open(lockfile, os.O_WRONLY|os.O_NOCTTY|os.O_CREAT, 0o666) + op = struct.pack('hhllhhl', fcntl.F_WRLCK, 0, 0, 0, 0, 0, 0) + fcntl.fcntl(fd, fcntl.F_SETLK, op) return subprocess.call(cmd_list) + +if __name__ == '__main__': + sys.exit(main(sys.argv[1:])) |