diff options
author | JP Abgrall <jpa@google.com> | 2013-02-13 16:31:58 -0800 |
---|---|---|
committer | JP Abgrall <jpa@google.com> | 2013-02-13 16:31:58 -0800 |
commit | a689d13a19ca729eee1f9a79e181976eabbd79dc (patch) | |
tree | 13c7d741b931e51255f3a0efab0278787079cadf /logwrapper | |
parent | 4869a68d56aaf3fefd2c1022bdab8571077e063c (diff) | |
download | system_core-a689d13a19ca729eee1f9a79e181976eabbd79dc.zip system_core-a689d13a19ca729eee1f9a79e181976eabbd79dc.tar.gz system_core-a689d13a19ca729eee1f9a79e181976eabbd79dc.tar.bz2 |
logwrap lib: make logwrapper less verbose when told to not log
We don't care about exit codes if logwrap output is not requested.
Change-Id: Ibae5fe53527554a1fe865c2058deb0a128a9dde2
Diffstat (limited to 'logwrapper')
-rw-r--r-- | logwrapper/logwrap.c | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/logwrapper/logwrap.c b/logwrapper/logwrap.c index a756eb3..d9247ec 100644 --- a/logwrapper/logwrap.c +++ b/logwrapper/logwrap.c @@ -32,7 +32,7 @@ #include "private/android_filesystem_config.h" #include "cutils/log.h" -#define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x))) +#define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x))) static int signal_fd_write; @@ -144,31 +144,34 @@ static int parent(const char *tag, int parent_read, int signal_fd, pid_t pid, } } - // Flush remaining data - if (a != b) { - buffer[b] = '\0'; - if (logwrap) - ALOG(LOG_INFO, btag, "%s", &buffer[a]); + if (chld_sts != NULL) { + *chld_sts = status; + } else { + if (WIFEXITED(status)) + rc = WEXITSTATUS(status); + else + rc = -ECHILD; } - if (WIFEXITED(status)) { + if (logwrap) { + // Flush remaining data + if (a != b) { + buffer[b] = '\0'; + ALOG(LOG_INFO, btag, "%s", &buffer[a]); + } + if (WIFEXITED(status)) { if (WEXITSTATUS(status)) - ALOG(LOG_INFO, "logwrapper", "%s terminated by exit(%d)", btag, - WEXITSTATUS(status)); - if (chld_sts == NULL) - rc = WEXITSTATUS(status); - } else { - if (chld_sts == NULL) - rc = -ECHILD; + ALOG(LOG_INFO, "logwrapper", "%s terminated by exit(%d)", btag, + WEXITSTATUS(status)); + } else { if (WIFSIGNALED(status)) - ALOG(LOG_INFO, "logwrapper", "%s terminated by signal %d", btag, - WTERMSIG(status)); + ALOG(LOG_INFO, "logwrapper", "%s terminated by signal %d", btag, + WTERMSIG(status)); else if (WIFSTOPPED(status)) - ALOG(LOG_INFO, "logwrapper", "%s stopped by signal %d", btag, - WSTOPSIG(status)); + ALOG(LOG_INFO, "logwrapper", "%s stopped by signal %d", btag, + WSTOPSIG(status)); + } } - if (chld_sts != NULL) - *chld_sts = status; err_poll: return rc; |