blob: 4929fbb3fe17a82110813817c5348b3fa65c544c [file] [log] [blame]
Guido van Rossum228b8e81997-04-02 06:13:34 +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
9from test_support import verbose
10
11filename = '/tmp/delete-me'
12
13# the example from the library docs
14f = open(filename,'w')
15rv = fcntl.fcntl(f.fileno(), FCNTL.O_NDELAY, 1)
16if verbose:
17 print 'Status from fnctl with O_NDELAY: ', rv
18
19lockdata = struct.pack('hhllhh', FCNTL.F_WRLCK, 0, 0, 0, 0, 0)
20if verbose:
21 print 'struct.pack: ', lockdata
22
23rv = fcntl.fcntl(f.fileno(), FCNTL.F_SETLKW, lockdata)
24if verbose:
25 print 'String from fcntl with F_SETLKW: ', rv
26
27f.close()
28os.unlink(filename)