[Python-bugs-list] [ python-Bugs-617870 ] fcntl.flock() doesn't work in solaris

noreply@sourceforge.net noreply@sourceforge.net
Wed, 02 Oct 2002 19:06:08 -0700


Bugs item #617870, was opened at 2002-10-02 21:06
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=617870&group_id=5470

Category: Python Library
Group: Platform-specific
Status: Open
Resolution: None
Priority: 5
Submitted By: Joćo Prado Maia (jcpm)
Assigned to: Nobody/Anonymous (nobody)
Summary: fcntl.flock() doesn't work in solaris

Initial Comment:
When trying the script below on Solaris:

# test_flock.py
import fcntl

def lock(fd, flags):
    fcntl.flock(fd.fileno(), flags)

def unlock(fd):
    fcntl.flock(fd.fileno(), fcntl.LOCK_UN)

fd = open('test.txt', 'w')
lock(fd, fcntl.LOCK_SH)
fd.write('testing')
unlock(fd)
fd.close()
# end of test_flock.py

$ uname -a
SunOS mercury 5.8 Generic_108529-13 i86pc i386 i86pc

I get the following output:

$ python test_flock.py
Traceback (most recent call last):
  File "test_flock.py", line 10, in ?
    lock(fd, fcntl.LOCK_SH)
  File "test_flock.py", line 4, in lock
    fcntl.flock(fd.fileno(), flags)
IOError: [Errno 9] Bad file number

This is the python version information:

$ python -V
Python 2.2.1

However, when I try the same script under Linux it works 
correctly (i.e. it creates the 'test.txt' file)

$ uname -a
Linux domain.com 2.4.9-31 #1 Tue Feb 26 07:11:02 
EST 2002 i686 unknown

Please let me know if you need any more information.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=617870&group_id=5470