diff options
author | Ethan Yonker <dees_troy@teamw.in> | 2019-03-22 14:18:21 +0100 |
---|---|---|
committer | Ethan Yonker <dees_troy@teamw.in> | 2019-03-22 14:18:24 +0100 |
commit | 7e941586844e514d296dd755972902dd64a4c8ba (patch) | |
tree | 0e512dab2b10d0ab3bf897b5815a59f607ffe9dc /twrp-functions.cpp | |
parent | Fix the long broken format function (diff) | |
download | android_bootable_recovery-7e941586844e514d296dd755972902dd64a4c8ba.tar android_bootable_recovery-7e941586844e514d296dd755972902dd64a4c8ba.tar.gz android_bootable_recovery-7e941586844e514d296dd755972902dd64a4c8ba.tar.bz2 android_bootable_recovery-7e941586844e514d296dd755972902dd64a4c8ba.tar.lz android_bootable_recovery-7e941586844e514d296dd755972902dd64a4c8ba.tar.xz android_bootable_recovery-7e941586844e514d296dd755972902dd64a4c8ba.tar.zst android_bootable_recovery-7e941586844e514d296dd755972902dd64a4c8ba.zip |
Diffstat (limited to 'twrp-functions.cpp')
-rwxr-xr-x | twrp-functions.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/twrp-functions.cpp b/twrp-functions.cpp index ff34828e2..84451b3b6 100755 --- a/twrp-functions.cpp +++ b/twrp-functions.cpp @@ -77,7 +77,7 @@ int TWFunc::Exec_Cmd(const string& cmd, string &result) { return ret; } -int TWFunc::Exec_Cmd(const string& cmd) { +int TWFunc::Exec_Cmd(const string& cmd, bool Show_Errors) { pid_t pid; int status; switch(pid = fork()) @@ -91,7 +91,7 @@ int TWFunc::Exec_Cmd(const string& cmd) { break; default: { - if (TWFunc::Wait_For_Child(pid, &status, cmd) != 0) + if (TWFunc::Wait_For_Child(pid, &status, cmd, Show_Errors) != 0) return -1; else return 0; @@ -121,18 +121,20 @@ string TWFunc::Get_Path(const string& Path) { return Path; } -int TWFunc::Wait_For_Child(pid_t pid, int *status, string Child_Name) { +int TWFunc::Wait_For_Child(pid_t pid, int *status, string Child_Name, bool Show_Errors) { pid_t rc_pid; rc_pid = waitpid(pid, status, 0); if (rc_pid > 0) { if (WIFSIGNALED(*status)) { - gui_msg(Msg(msg::kError, "pid_signal={1} process ended with signal: {2}")(Child_Name)(WTERMSIG(*status))); // Seg fault or some other non-graceful termination + if (Show_Errors) + gui_msg(Msg(msg::kError, "pid_signal={1} process ended with signal: {2}")(Child_Name)(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 { - gui_msg(Msg(msg::kError, "pid_error={1} process ended with ERROR: {2}")(Child_Name)(WEXITSTATUS(*status))); // Graceful exit, but there was an error + if (Show_Errors) + gui_msg(Msg(msg::kError, "pid_error={1} process ended with ERROR: {2}")(Child_Name)(WEXITSTATUS(*status))); // Graceful exit, but there was an error return -1; } } else { // no PID returned |