From 408fa57864c01113deaa213e5c1848a9c594ae92 Mon Sep 17 00:00:00 2001 From: JP Abgrall Date: Wed, 16 Mar 2011 15:57:42 -0700 Subject: adb: fix subprocess exit handling, oom adjust fixes, extra debugging. * Add support for correctly handling subprocess termination in shell service (b/3400254 b/3482112 b/2249397) - have a waitpid() track the subprocess, then notify the fdevent via a socket - force an eof on the pty master in fdevent's new subproc handler. - modify fdevent to force-read the pty after an exit. * Migrate the "shell:blabla" handling to "#if !ADB_HOST" sections, where it belongs. * Fix the race around OOM adjusting. - Do it in the child before exec() instead of the in the parent as the child could already have started or not (no /proc/pid/... yet). * Allow for multi-threaded D() invocations to not clobber each other. - Allow locks across object files. - Add lock within D() - Make sure sysdesp init (mutex init also) is called early. * Add some missing close(fd) calls - Match similar existing practices near dup2() * Add extra D() invocations related to FD handling. * Warn about using debugging as stderr/stdout is used for protocol. * Fix some errno handling and make D() correctly handle it. * Add new adb trace_mask: services. * Make fdevent_loop's handle BADFDs more gracefully (could occur some subproc closed its pts explicitely). * Remove obsolete commandline args reported in help. (b/3509092) Change-Id: I928287fdf4f1a86777e22ce105f9581685f46e35 --- adb/usb_linux_client.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'adb/usb_linux_client.c') diff --git a/adb/usb_linux_client.c b/adb/usb_linux_client.c index 0a21c6f..635fa4b 100644 --- a/adb/usb_linux_client.c +++ b/adb/usb_linux_client.c @@ -83,14 +83,14 @@ int usb_write(usb_handle *h, const void *data, int len) { int n; - D("[ write %d ]\n", len); + D("about to write (fd=%d, len=%d)\n", h->fd, len); n = adb_write(h->fd, data, len); if(n != len) { - D("ERROR: n = %d, errno = %d (%s)\n", - n, errno, strerror(errno)); + D("ERROR: fd = %d, n = %d, errno = %d (%s)\n", + h->fd, n, errno, strerror(errno)); return -1; } - D("[ done ]\n"); + D("[ done fd=%d ]\n", h->fd); return 0; } @@ -98,13 +98,14 @@ int usb_read(usb_handle *h, void *data, int len) { int n; - D("[ read %d ]\n", len); + D("about to read (fd=%d, len=%d)\n", h->fd, len); n = adb_read(h->fd, data, len); if(n != len) { - D("ERROR: n = %d, errno = %d (%s)\n", - n, errno, strerror(errno)); + D("ERROR: fd = %d, n = %d, errno = %d (%s)\n", + h->fd, n, errno, strerror(errno)); return -1; } + D("[ done fd=%d ]\n", h->fd); return 0; } -- cgit v1.1