diff options
| author | Elliott Hughes <enh@google.com> | 2014-08-26 16:20:59 -0700 |
|---|---|---|
| committer | Elliott Hughes <enh@google.com> | 2014-08-26 16:20:59 -0700 |
| commit | f73183f1a34df22b62a3d0bbf82e18d5797c9cde (patch) | |
| tree | 1bc3c9a47180aaeb2f734e835034a3f6b9ac9d00 /libc/bionic/system_properties.cpp | |
| parent | 7b87d441b0f2aa3ad5021ab6bd879a995a1bc2ce (diff) | |
| download | bionic-f73183f1a34df22b62a3d0bbf82e18d5797c9cde.zip bionic-f73183f1a34df22b62a3d0bbf82e18d5797c9cde.tar.gz bionic-f73183f1a34df22b62a3d0bbf82e18d5797c9cde.tar.bz2 | |
More cases where libc should use O_CLOEXEC.
Change-Id: Idfa111aeebc5deca2399dae919e8b72eb54c23c0
Diffstat (limited to 'libc/bionic/system_properties.cpp')
| -rw-r--r-- | libc/bionic/system_properties.cpp | 21 |
1 files changed, 2 insertions, 19 deletions
diff --git a/libc/bionic/system_properties.cpp b/libc/bionic/system_properties.cpp index ad69cf5..411d6bf 100644 --- a/libc/bionic/system_properties.cpp +++ b/libc/bionic/system_properties.cpp @@ -201,14 +201,6 @@ static int map_prop_area_rw() return -1; } - // TODO: Is this really required ? Does android run on any kernels that - // don't support O_CLOEXEC ? - const int ret = fcntl(fd, F_SETFD, FD_CLOEXEC); - if (ret < 0) { - close(fd); - return -1; - } - if (ftruncate(fd, PA_SIZE) < 0) { close(fd); return -1; @@ -271,18 +263,9 @@ static int map_fd_ro(const int fd) { static int map_prop_area() { - int fd(open(property_filename, O_RDONLY | O_NOFOLLOW | O_CLOEXEC)); - if (fd >= 0) { - /* For old kernels that don't support O_CLOEXEC */ - const int ret = fcntl(fd, F_SETFD, FD_CLOEXEC); - if (ret < 0) { - close(fd); - return -1; - } - } - + int fd = open(property_filename, O_CLOEXEC | O_NOFOLLOW | O_RDONLY); bool close_fd = true; - if ((fd < 0) && (errno == ENOENT)) { + if (fd == -1 && errno == ENOENT) { /* * For backwards compatibility, if the file doesn't * exist, we use the environment to get the file descriptor. |
