diff --git a/libcutils/qtaguid.c b/libcutils/qtaguid.c index 00e211c77..14a58ca74 100644 --- a/libcutils/qtaguid.c +++ b/libcutils/qtaguid.c @@ -47,10 +47,7 @@ pthread_once_t resTrackInitDone = PTHREAD_ONCE_INIT; /* Only call once per process. */ void qtaguid_resTrack(void) { - resTrackFd = TEMP_FAILURE_RETRY(open("/dev/xt_qtaguid", O_RDONLY)); - if (resTrackFd >=0) { - TEMP_FAILURE_RETRY(fcntl(resTrackFd, F_SETFD, FD_CLOEXEC)); - } + resTrackFd = TEMP_FAILURE_RETRY(open("/dev/xt_qtaguid", O_RDONLY | O_CLOEXEC)); } /* @@ -63,7 +60,7 @@ static int write_ctrl(const char *cmd) { ALOGV("write_ctrl(%s)", cmd); - fd = TEMP_FAILURE_RETRY(open(CTRL_PROCPATH, O_WRONLY)); + fd = TEMP_FAILURE_RETRY(open(CTRL_PROCPATH, O_WRONLY | O_CLOEXEC)); if (fd < 0) { return -errno; } @@ -85,7 +82,7 @@ static int write_param(const char *param_path, const char *value) { int param_fd; int res; - param_fd = TEMP_FAILURE_RETRY(open(param_path, O_WRONLY)); + param_fd = TEMP_FAILURE_RETRY(open(param_path, O_WRONLY | O_CLOEXEC)); if (param_fd < 0) { return -errno; }