summaryrefslogtreecommitdiff
path: root/opengl/libagl/BufferObjectManager.cpp
diff options
context:
space:
mode:
author Nick Kralevich <nnk@google.com> 2019-04-01 09:08:53 -0700
committer Nick Kralevich <nnk@google.com> 2019-04-01 09:17:19 -0700
commit9bb358f520fed10e57abc685bd3796cef7c0015e (patch)
treed59bdd898675ac95f1d88e01a7a12b50bd551242 /opengl/libagl/BufferObjectManager.cpp
parent041c8ab48f062beddcee7fa3ccea6e0ad88cf0e2 (diff)
view_compiler.cpp: clean up file descriptor handling
For file descriptors which are explicitly passed across an exec() boundary, mark them as // NOLINT(android-cloexec-open). This suppresses clang-tidy link checks (intended to be added as part of b/129350825) Don't call close(STDOUT_FILENO). The dup2() syscall atomically closes this for us, so we don't need to do it ourselves. Additionally, this also fixes a race condition where another thread may call open() and get an FD corresponding to STDOUT_FILENO, which we will then close as part of the dup2() call. Removing the close() makes file descriptor handling atomic. Set O_CLOEXEC on outfd. The pre-duped file descriptor should have O_CLOEXEC set on it. Calling dup2() will dup the file descriptor, but NOT preserve the O_CLOEXEC flag. Quoting "man dup2": The two file descriptors do not share file descriptor flags (the close-on-exec flag). The close-on-exec flag (FD_CLOEXEC; see fcntl(2)) for the duplicate descriptor is off. If we don't set the O_CLOEXEC flag on outfd, we'll be leaking the file descriptor twice, once as STDOUT_FILENO, and once as outfd. The second leak is undesirable although harmless. Additional cleanup: Add missing newlines at end of file. Bug: 129350825 Test: compiles Change-Id: Ic83ad72ef8a38106ad95ec0202c5c09c61fcf3e7
Diffstat (limited to 'opengl/libagl/BufferObjectManager.cpp')
0 files changed, 0 insertions, 0 deletions