blob: 76391343f6ac47272e630600dbefe9eb2a62cdfc [file] [log] [blame]
Roger E. Massefb01d4b1996-12-17 17:41:09 +00001#! /usr/bin/env python
2"""Test program for the fcntl C module.
3 Roger E. Masse
4"""
5import struct
6import fcntl
7import FCNTL
8import os
9
10verbose = 0
11if __name__ == '__main__':
12 verbose = 1
13
14filename = '/tmp/delete-me'
15
16# the example from the library docs
17f = open(filename,'w')
18rv = fcntl.fcntl(f.fileno(), FCNTL.O_NDELAY, 1)
19if verbose:
20 print 'Status from fnctl with O_NDELAY: ', rv
21
22lockdata = struct.pack('hhllhh', FCNTL.F_WRLCK, 0, 0, 0, 0, 0)
23if verbose:
24 print 'struct.pack: ', lockdata
25
26rv = fcntl.fcntl(f.fileno(), FCNTL.F_SETLKW, lockdata)
27if verbose:
28 print 'String from fcntl with F_SETLKW: ', rv
29
30f.close()
31os.unlink(filename)