Bug 127842

Summary: Fix wrong mix of fcntl commands and flags
Product: WebKit Reporter: Alberto Garcia <berto>
Component: New BugsAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: sergio
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch darin: review+

Description Alberto Garcia 2014-01-29 10:10:32 PST
Using F_SETFL to set the FD_CLOEXEC flag in the following code is
wrong, the correct command here is F_SETFD.

    while (fcntl(fileDescriptors[i], F_SETFL, FD_CLOEXEC) == -1) {
        if (errno != EINTR) {
            ASSERT_NOT_REACHED();
            break;
        }
    }
Comment 1 Alberto Garcia 2014-01-29 10:14:13 PST
Created attachment 222579 [details]
Patch
Comment 2 Sergio Correia (qrwteyrutiyoup) 2014-01-30 16:17:24 PST
Nice catch!

After a quick look, SharedMemory::createHandle() 
[WebKit2/Platform/unix/SharedMemoryUnix.cpp] seems suspicious, as in it does
fcntl(duplicatedHandle, F_SETFD, FD_CLOEXEC | accessModeFile(protection)) == -1).
Seems like it should be F_SETFD for FD_CLOEXEC and F_SETFL for the access mode (O_RDONLY or O_RDWR, in this case), no?
Comment 3 Alberto Garcia 2014-01-31 00:29:55 PST
I think you're right, I'll update the patch.
Comment 4 Alberto Garcia 2014-01-31 00:35:33 PST
Created attachment 222804 [details]
Patch
Comment 5 Darin Adler 2014-01-31 12:19:05 PST
Comment on attachment 222804 [details]
Patch

Would be much better if these had test coverage.
Comment 6 Alberto Garcia 2014-02-03 00:14:39 PST
Committed r163292: <http://trac.webkit.org/changeset/163292>