Python fcntl Test

From PeformIQ Upgrade
Jump to navigation Jump to search
#! /usr/bin/env python2.2
"""Test program for the fcntl C module.
   Roger E. Masse
"""
import struct
import fcntl
import os, sys

import datetime

curr = datetime.datetime.now()

print curr

sys.exit(0)

filename = sys.argv[1]

# Again, but pass the file rather than numeric descriptor:
f = open(filename, 'a+')

rv = fcntl.flock(f, fcntl.LOCK_EX)

import time

time.sleep (60)

rv = fcntl.flock(f, fcntl.LOCK_UN)

f.close()