Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Unified Diff: tools/android/adb_reboot/adb_reboot.c

Issue 1841863002: Update monet. (Closed) Base URL: https://github.com/domokit/monet.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/android/VERSION_MACOSX_SDK ('k') | tools/android/adb_remote_setup.sh » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/android/adb_reboot/adb_reboot.c
diff --git a/tools/android/adb_reboot/adb_reboot.c b/tools/android/adb_reboot/adb_reboot.c
new file mode 100644
index 0000000000000000000000000000000000000000..d414dd5d3583a2c41d9136a0ede88661d700c38e
--- /dev/null
+++ b/tools/android/adb_reboot/adb_reboot.c
@@ -0,0 +1,43 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <unistd.h>
+
+int main(int argc, char ** argv) {
+ int i = fork();
+ struct stat ft;
+ time_t ct;
+
+ if (i < 0) {
+ printf("fork error");
+ return 1;
+ }
+ if (i > 0)
+ return 0;
+
+ /* child (daemon) continues */
+ int j;
+ for (j = 0; j < sysconf(_SC_OPEN_MAX); j++)
+ close(j);
+
+ setsid(); /* obtain a new process group */
+
+ while (1) {
+ sleep(120);
+
+ stat("/sdcard/host_heartbeat", &ft);
+ time(&ct);
+ if (ct - ft.st_mtime > 120) {
+ /* File was not touched for some time. */
+ system("su -c reboot");
+ }
+ }
+
+ return 0;
+}
« no previous file with comments | « tools/android/VERSION_MACOSX_SDK ('k') | tools/android/adb_remote_setup.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698