open() creates a new file even if it fails with EMFILE

Christian Franke Christian.Franke@t-online.de
Tue May 5 09:15:59 GMT 2026


Mark Geisert via Cygwin wrote:
> Hi Christian,
>
> On 5/4/2026 11:39 AM, Christian Franke via Cygwin wrote:
>> Could be reproduced with 3.6.9 and current HEAD.
>>
>> Testcase:
>>
>> ...
>>
>> Looks like the fd is allocated too late.
>
> Thanks for the report and especially for the STC.  It is during 
> fdtable extension that the limit is checked; by then NtCreateFile() 
> has already been called successfully.  We need to consider a fix that 
> avoids needlessly creating a file that can't be operated on anyway.

You're welcome. I will add an enhanced version of the STC to the 
cygwin-apps/stc repo. Problem was detected by 'stress-ng --open ...' 
with stress-ng 0.21.01-1.

-- 
Regards,
Christian



More information about the Cygwin mailing list