Skip to content

Instantly share code, notes, and snippets.

@tjfontaine
Created January 26, 2014 19:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tjfontaine/8637719 to your computer and use it in GitHub Desktop.
Save tjfontaine/8637719 to your computer and use it in GitHub Desktop.
>>> import os,fcntl,struct
>>> fd = os.open('file', os.O_WRONLY|os.O_NOCTTY|os.O_CREAT, 0666)
>>> op = struct.pack('hhllhhl', fcntl.F_WRLCK, 0, 0, 0, 0, 0, 0)
>>>
>>> fcntl.fcntl(fd, fcntl.F_SETLK, op)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment