[ python-Bugs-1424041 ] The mmap module does unnecessary dup()

SourceForge.net noreply at sourceforge.net
Sat Feb 4 15:33:57 CET 2006


Bugs item #1424041, was opened at 2006-02-04 05:39
Message generated for change (Comment added) made by kdart
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1424041&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Keith Dart (kdart)
Assigned to: Neal Norwitz (nnorwitz)
Summary: The mmap module does unnecessary dup()

Initial Comment:
The following no longer works in Python 2.4:

_buf = mmap.mmap(-1, 8192,
flags=mmap.MAP_PRIVATE|mmap.MAP_ANONYMOUS,
prot=mmap.PROT_READ|mmap.PROT_WRITE )

This is because the fd value of -1 raises an exception
because it is being dup-ed inside the mmap module. But
the fd is ignored in anonymous mmaps and does not need
to be dup-ed. This worked in older Python (2.3). Is the
dup() call really necessary? My current workaround is
to open /dev/null. But this causes "invisible"
consumption of file descriptors for the process.

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

>Comment By: Keith Dart (kdart)
Date: 2006-02-04 06:33

Message:
Logged In: YES 
user_id=16527

Here is a patch that fixes the problem for anonymous maps.
It simply makes the fd to be ignored if it is less than
zero. This works, but I still don't think having a duped fd
is needed. Whatever it accomplishes could be done in Python.
As a general rule, I prefer these kinds os system call
wrappers to do as little as possible (just wrap the call). 

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

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


More information about the Python-bugs-list mailing list