Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2e12030c authored by Mark Salyzyn's avatar Mark Salyzyn Committed by android-build-merger
Browse files

Merge "reboot: only pause indefinitely for non-shutdown operations"

am: e808f921

Change-Id: I8386ad08ff53f94b78bae713f614f962a92637d2
parents bc3d3625 e808f921
Loading
Loading
Loading
Loading
+12 −8
Original line number Diff line number Diff line
@@ -21,12 +21,12 @@
#include <cutils/android_reboot.h>
#include <unistd.h>

int main(int argc, char *argv[])
{
int main(int argc, char* argv[]) {
    int ret;
    size_t prop_len;
    char property_val[PROPERTY_VALUE_MAX];
    const char *cmd = "reboot";
    static const char reboot[] = "reboot";
    const char* cmd = reboot;
    char* optarg = "";

    opterr = 0;
@@ -60,19 +60,23 @@ int main(int argc, char *argv[])

    prop_len = snprintf(property_val, sizeof(property_val), "%s,%s", cmd, optarg);
    if (prop_len >= sizeof(property_val)) {
        fprintf(stderr, "reboot command too long: %s\n", optarg);
        fprintf(stderr, "%s command too long: %s\n", cmd, optarg);
        exit(EXIT_FAILURE);
    }

    ret = property_set(ANDROID_RB_PROPERTY, property_val);
    if (ret < 0) {
        perror("reboot");
        perror(cmd);
        exit(EXIT_FAILURE);
    }

    // Don't return early. Give the reboot command time to take effect
    // to avoid messing up scripts which do "adb shell reboot && adb wait-for-device"
    while(1) { pause(); }
    if (cmd == reboot) {
        while (1) {
            pause();
        }
    }

    fprintf(stderr, "Done\n");
    return 0;