This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: second call to mmap() results in error
- From: "Larry Hall (Cygwin)" <reply-to-list-only-lh at cygwin dot com>
- To: cygwin at cygwin dot com
- Date: Thu, 30 Jan 2014 14:30:16 -0500
- Subject: Re: second call to mmap() results in error
- Authentication-results: sourceware.org; auth=none
- References: <20140129181250 dot GW2821 at calimero dot vinschen dot de> <52E95786 dot 8050606 at gmail dot com> <20140130095822 dot GY2821 at calimero dot vinschen dot de> <001801cf1db6$66c47c40$344d74c0$ at lbmsys dot com> <20140130124558 dot GA2821 at calimero dot vinschen dot de> <003801cf1dbd$fc3ffc70$f4bff550$ at lbmsys dot com> <20140130170142 dot GD2821 at calimero dot vinschen dot de> <5F8AAC04F9616747BC4CC0E803D5907D0C4763CC at MLBXv04 dot nih dot gov> <52EA9A53 dot 2050203 at cygwin dot com> <5F8AAC04F9616747BC4CC0E803D5907D0C4764C5 at MLBXv04 dot nih dot gov> <20140130183956 dot GA3573 at ednor dot casa dot cgf dot cx> <5F8AAC04F9616747BC4CC0E803D5907D0C4764ED at MLBXv04 dot nih dot gov> <52EA9EA2 dot 5030202 at cygwin dot com> <5F8AAC04F9616747BC4CC0E803D5907D0C476528 at MLBXv04 dot nih dot gov> <52EAA171 dot 406 at cygwin dot com> <5F8AAC04F9616747BC4CC0E803D5907D0C4765D8 at MLBXv04 dot nih dot gov>
- Reply-to: cygwin at cygwin dot com
On 1/30/2014 2:04 PM, Lavrentiev, Anton (NIH/NLM/NCBI) [C] wrote:
Forget mmap().
Why? The response was:
Adding the <unistd.h> fixes the problem in all its iterations -- the original mmap()
test works (without the call to ftruncate()), as well as the second one.
Note *the original*.
<http://cygwin.com/ml/cygwin/2014-01/msg00494.html>. Note here Corinna
says:
Your testcase is missing an ftruncate or two., btw.
So if the question is why do you need to include ftruncate() in the code,
take a look here:
<http://pubs.opengroup.org/onlinepubs/009695399/functions/mmap.html>.
In particular:
Note that references beyond the end of the object do not extend the
object as the new end cannot be determined precisely by most virtual
memory hardware. Instead, the size can be directly manipulated by
ftruncate().
So the code as written requires ftruncate() to work in a defined manner.
But if you don't include unistd.h, you don't get the prototype and you
end up with ftruncate() failing, which causes mmap() to fail.
--
Larry
_____________________________________________________________________
A: Yes.
> Q: Are you sure?
>> A: Because it reverses the logical flow of conversation.
>>> Q: Why is top posting annoying in email?
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple