fix adb sideload

- "Cancel" button handling requires another thread
- simplify handling of child pid
- merge duplicated code for reinjecting TWRP after installation
- fix error that showed on host PC after sideload finished
- fix problem where adbd sometimes does not stop correctly

Change-Id: I536877f024b606756c6a3289c6ddfdba423a60d6
diff --git a/twrp.cpp b/twrp.cpp
index e0b3359..35404c3 100644
--- a/twrp.cpp
+++ b/twrp.cpp
@@ -77,6 +77,7 @@
 
 	// Handle ADB sideload
 	if (argc == 3 && strcmp(argv[1], "--adbd") == 0) {
+		property_set("ctl.stop", "adbd");
 		adb_main(argv[2]);
 		return 0;
 	}
@@ -95,7 +96,7 @@
 	property_set("ro.twrp.version", TW_VERSION_STR);
 
 	time_t StartupTime = time(NULL);
-	printf("Starting TWRP %s on %s (pid %d)", TW_VERSION_STR, ctime(&StartupTime), getpid());
+	printf("Starting TWRP %s on %s (pid %d)\n", TW_VERSION_STR, ctime(&StartupTime), getpid());
 
 	// Load default values to set DataManager constants and handle ifdefs
 	DataManager::SetDefaultValues();