11 def handler(signum, frame):
16 lockdata = struct.pack('hhllhh', fcntl.F_WRLCK, 0, 0, 10, 0, 0)
17 fcntl.fcntl(f1, fcntl.F_SETLKW, lockdata)
21 signal.signal(signal.SIGALRM, handler)
25 fcntl.fcntl(f2, fcntl.F_SETLKW, lockdata)
27 if e.errno == errno.EDEADLK:
29 elif e.errno == errno.EINTR:
39 f1 = open("testfile1", 'w')
40 f2 = open("testfile2", 'w')
45 f1 = open("testfile2", 'w')
46 f2 = open("testfile3", 'w')
51 f1 = open("testfile3", 'w')
52 f2 = open("testfile1", 'w')
58 pid, status = os.wait()
59 exitcode = status >> 8
63 raise RuntimeError("unexpect exit code of child")
67 raise RuntimeError("unexpect count of EDEADLK")