diff options
author | Nick Kralevich <nnk@google.com> | 2014-07-18 20:57:35 -0700 |
---|---|---|
committer | Nick Kralevich <nnk@google.com> | 2014-07-21 19:34:31 -0700 |
commit | 9866a66d6d1b9898c6c29ff390358fe8dc2c7d77 (patch) | |
tree | 3efba5a2ccd24b85f23677c1c0e4544914b32809 /adb/usb_linux.c | |
parent | 02c7113deea592081c09aca90771670db8918d6c (diff) | |
download | system_core-9866a66d6d1b9898c6c29ff390358fe8dc2c7d77.zip system_core-9866a66d6d1b9898c6c29ff390358fe8dc2c7d77.tar.gz system_core-9866a66d6d1b9898c6c29ff390358fe8dc2c7d77.tar.bz2 |
adb: set O_CLOEXEC on lots of file descriptors
Too many leaking FDs.
Fixes bug: https://code.google.com/p/android/issues/detail?id=65857
(and more)
(cherrypicked from commit fe8d7f4f2e775d46d61f7c2d29a4e852434984da)
Change-Id: I67d8683244e54288a8105f6f65ee40abe2378d7e
Diffstat (limited to 'adb/usb_linux.c')
-rw-r--r-- | adb/usb_linux.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/adb/usb_linux.c b/adb/usb_linux.c index 8ff753e..f16bdd0 100644 --- a/adb/usb_linux.c +++ b/adb/usb_linux.c @@ -170,7 +170,7 @@ static void find_usb_device(const char *base, } // DBGX("[ scanning %s ]\n", devname); - if((fd = unix_open(devname, O_RDONLY)) < 0) { + if((fd = unix_open(devname, O_RDONLY | O_CLOEXEC)) < 0) { continue; } @@ -597,10 +597,10 @@ static void register_device(const char *dev_name, const char *devpath, usb->mark = 1; usb->reaper_thread = 0; - usb->desc = unix_open(usb->fname, O_RDWR); + usb->desc = unix_open(usb->fname, O_RDWR | O_CLOEXEC); if(usb->desc < 0) { /* if we fail, see if have read-only access */ - usb->desc = unix_open(usb->fname, O_RDONLY); + usb->desc = unix_open(usb->fname, O_RDONLY | O_CLOEXEC); if(usb->desc < 0) goto fail; usb->writeable = 0; D("[ usb open read-only %s fd = %d]\n", usb->fname, usb->desc); |