summaryrefslogtreecommitdiffstats
path: root/logwrapper.c
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@android.com>2010-09-20 11:11:46 -0700
committerBrad Fitzpatrick <bradfitz@android.com>2010-09-20 11:11:46 -0700
commit1b15d463d4816fc084767cbeda3ee69ff5527545 (patch)
tree079d27f262028a569cc65352fb102e369309b64a /logwrapper.c
parent2dfe297ec47559dbe2297a72bea71cf515c03797 (diff)
downloadandroid_system_vold-1b15d463d4816fc084767cbeda3ee69ff5527545.tar.gz
android_system_vold-1b15d463d4816fc084767cbeda3ee69ff5527545.tar.bz2
android_system_vold-1b15d463d4816fc084767cbeda3ee69ff5527545.zip
Add some missing closes on error conditions.
Also, some formatting fixes to get back into line with netd's copy of logwrapper.c. Change-Id: Id471b99e9c3c8c9bb0890ca0d5e1567125e35bd7
Diffstat (limited to 'logwrapper.c')
-rw-r--r--logwrapper.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/logwrapper.c b/logwrapper.c
index 4862efb..b7d2f68 100644
--- a/logwrapper.c
+++ b/logwrapper.c
@@ -72,8 +72,10 @@ int parent(const char *tag, int parent_read) {
status = 0xAAAA;
if (wait(&status) != -1) { // Wait for child
if (WIFEXITED(status)) {
- LOG(LOG_INFO, "logwrapper", "%s terminated by exit(%d)", tag,
- WEXITSTATUS(status));
+ if (WEXITSTATUS(status) != 0) {
+ LOG(LOG_INFO, "logwrapper", "%s terminated by exit(%d)", tag,
+ WEXITSTATUS(status));
+ }
return WEXITSTATUS(status);
} else if (WIFSIGNALED(status))
LOG(LOG_INFO, "logwrapper", "%s terminated by signal %d", tag,
@@ -118,13 +120,14 @@ int logwrap(int argc, const char* argv[], int background)
if (grantpt(parent_ptty) || unlockpt(parent_ptty) ||
((child_devname = (char*)ptsname(parent_ptty)) == 0)) {
- LOG(LOG_ERROR, "logwrapper", "Problem with /dev/ptmx");
close(parent_ptty);
+ LOG(LOG_ERROR, "logwrapper", "Problem with /dev/ptmx");
return -1;
}
pid = fork();
if (pid < 0) {
+ close(parent_ptty);
LOG(LOG_ERROR, "logwrapper", "Failed to fork");
return -errno;
} else if (pid == 0) {
@@ -133,6 +136,7 @@ int logwrap(int argc, const char* argv[], int background)
*/
child_ptty = open(child_devname, O_RDWR);
if (child_ptty < 0) {
+ close(parent_ptty);
LOG(LOG_ERROR, "logwrapper", "Problem with child ptty");
return -errno;
}
@@ -145,10 +149,8 @@ int logwrap(int argc, const char* argv[], int background)
if (background) {
int fd = open("/dev/cpuctl/bg_non_interactive/tasks", O_WRONLY);
-
- if (fd >=0 ) {
+ if (fd >= 0) {
char text[64];
-
sprintf(text, "%d", getpid());
if (write(fd, text, strlen(text)) < 0) {
LOG(LOG_WARN, "logwrapper",