From 118d1b393067fbc4fbb26af6815a7a4f131f0148 Mon Sep 17 00:00:00 2001 From: Nick Kralevich Date: Wed, 2 Jul 2014 22:30:39 -0700 Subject: [PATCH] logd_write: set SOCK_CLOEXEC on socket Socket file descriptors remain open across exec unless SOCK_CLOEXEC is set. Enable this option, to avoid leaking file descriptors. See https://android-review.googlesource.com/53736 for a similar problem with the old logging code. Change-Id: I9e045d2291ae6680044ab86604f3ff2c55b5eaed --- liblog/logd_write.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/liblog/logd_write.c b/liblog/logd_write.c index 1da55ab98..3171c78e1 100644 --- a/liblog/logd_write.c +++ b/liblog/logd_write.c @@ -107,7 +107,7 @@ static int __write_to_log_initialize() close(i); } - i = socket(PF_UNIX, SOCK_DGRAM, 0); + i = socket(PF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC, 0); if (i < 0) { ret = -errno; write_to_log = __write_to_log_null;