Fix CreateAnonymousSharedMemory() not to leak FILE when returning fd.

CreateAnonymousSharedMemory() was modified to return the writable memory
handle as a file-descriptor rather than as a FILE. Since POSIX does not
provide a standard way to teardown a FILE without also close()ing the
underlying file-descriptor, this was achieved by leaking the FILE.

We now provide CreateAndOpenFdForTemporaryFileInDir(), to avoid the need
to wrap the temporary-file descriptor into a FILE at all.

Bug: 814444, 736452
Change-Id: Idd911f50f0e506de3eac91c809efb6c6d59fec10
Reviewed-by: Lei Zhang <>
Reviewed-by: Robert Sesek <>
Commit-Queue: Wez <>
Cr-Original-Commit-Position: refs/heads/master@{#538599}(cherry picked from commit 45a7b305282b175e11c871c1a8ac3b8336c66259)
Reviewed-by: Wez <>
Cr-Commit-Position: refs/branch-heads/3325@{#615}
Cr-Branched-From: bc084a8b5afa3744a74927344e304c02ae54189f-refs/heads/master@{#530369}
3 files changed