OSDN Git Service

TetherController: Use correct exit() after fork()+failed exec().
authorJP Abgrall <jpa@google.com>
Mon, 6 Aug 2012 20:44:44 +0000 (13:44 -0700)
committerJP Abgrall <jpa@google.com>
Mon, 6 Aug 2012 20:44:44 +0000 (13:44 -0700)
The bluetooth hack I98a1c8aedfa042b1824de7d8c69f2600c9bfcf29 uses the
wrong exit() after the exec() fail.
This will have undesirable effects like cpp destructors and atexit() funcs
being invoked which could have undesirable effects for the parent.
Also fixed other prior instance of fork()+exec()+"return"

Change-Id: I8c09472a371640a710c55fc18e020b9c152bf9cc

TetherController.cpp

index 5f571a1..cb48dbc 100644 (file)
@@ -158,8 +158,7 @@ int TetherController::startTethering(int num_addrs, struct in_addr* addrs) {
             ALOGE("execl failed (%s)", strerror(errno));
         }
         ALOGE("Should never get here!");
-        free(args);
-        return 0;
+        _exit(-1);
     } else {
         close(pipefd[0]);
         mDaemonPid = pid;
@@ -233,7 +232,7 @@ int TetherController::startReverseTethering(const char* iface) {
         // TODO(BT) inform parent of the failure.
         //          Parent process need wait for child to report error status
         //          before it set mDhcpcdPid and return 0.
-        exit(-1);
+        _exit(-1);
     } else {
         mDhcpcdPid = pid;
         ALOGD("Reverse Tethering running, pid:%d", pid);