Fix a type mismatch on Windows caused by r201738.
[chromium-blink-merge.git] / tools / android / adb_reboot / adb_reboot.c
bloba8115fcfab33957f568a5b129d29c946a7cd763d
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include <sys/types.h>
6 #include <sys/stat.h>
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <time.h>
10 #include <unistd.h>
12 int main(int argc, char ** argv) {
13 int i = fork();
14 struct stat ft;
15 time_t ct;
17 if (i < 0) {
18 printf("fork error");
19 return 1;
21 if (i > 0)
22 return 0;
24 /* child (daemon) continues */
25 int j;
26 for (j = 0; j < getdtablesize(); j++)
27 close(j);
29 setsid(); /* obtain a new process group */
31 while (1) {
32 sleep(120);
34 stat("/sdcard/host_heartbeat", &ft);
35 time(&ct);
36 if (ct - ft.st_mtime > 120) {
37 /* File was not touched for some time. */
38 system("su -c stop adbd");
39 system("sleep 2");
40 system("su -c start adbd");
44 return 0;