NSFileHandle returns the wrong error code on MacOS High Sierra

Number:rdar://36835094 Date Originated:January 24 2018
Status:Open Resolved:
Product:macOS + SDK Product Version:macOS High Sierra
Classification:Other Reproducible:Always
`-[NSFileHandle fileHandleWritingToURL:error:]` returns the error code `EINTR` (Interrupted system call) when the URL points to a local file that does not exist instead of the old `ENOENT`(No such file or directory). The error code changed on iOS 11.0 as compared with iOS 10.3 (possibly as far back as iOS 4). The same bug manifests itself between MacOS Sierra running HFS+ and MacOS High Sierra running APFS.

Steps to Reproduce:
Call fileHandleWritingToURL:error: with a non-existent file path and inspect the resulting error code.

Expected Results:
The error code should be `ENOENT`.

Actual Results:
The error code is `EINTR`.

iOS 11.0, iOS 11.1, iOS 11.2, MacOS High Sierra

iPhone 6, Macbook Pro 2017


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!