twrpTar: fix segfault after encrypted backups
also use unsigned int for core_count instead of unsigned long long.
I'll change it back when 4-billion-core devices are common.
PS2
- cast return value via intptr_t (may be important for 64 bit platforms)
- output errors from TWFunc::Wait_For_Child to console
Change-Id: I04158daa0b64e44d68e179d626a83d81cf5d49f7
diff --git a/twrp-functions.cpp b/twrp-functions.cpp
index f773df6..b6f9c56 100644
--- a/twrp-functions.cpp
+++ b/twrp-functions.cpp
@@ -125,19 +125,19 @@
rc_pid = waitpid(pid, status, 0);
if (rc_pid > 0) {
if (WIFSIGNALED(*status)) {
- LOGINFO("%s process ended with signal: %d\n", Child_Name.c_str(), WTERMSIG(*status)); // Seg fault or some other non-graceful termination
+ LOGERR("%s process ended with signal: %d\n", Child_Name.c_str(), WTERMSIG(*status)); // Seg fault or some other non-graceful termination
return -1;
} else if (WEXITSTATUS(*status) == 0) {
LOGINFO("%s process ended with RC=%d\n", Child_Name.c_str(), WEXITSTATUS(*status)); // Success
} else {
- LOGINFO("%s process ended with ERROR=%d\n", Child_Name.c_str(), WEXITSTATUS(*status)); // Graceful exit, but there was an error
+ LOGERR("%s process ended with ERROR=%d\n", Child_Name.c_str(), WEXITSTATUS(*status)); // Graceful exit, but there was an error
return -1;
}
} else { // no PID returned
if (errno == ECHILD)
- LOGINFO("%s no child process exist\n", Child_Name.c_str());
+ LOGERR("%s no child process exist\n", Child_Name.c_str());
else {
- LOGINFO("%s Unexpected error\n", Child_Name.c_str());
+ LOGERR("%s Unexpected error %d\n", Child_Name.c_str(), errno);
return -1;
}
}