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

Side by Side Diff: tools/android/adb_reboot/adb_reboot.c

Issue 12733012: Provision Android devices after the 'device_status_check' step. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove process detachment Created 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <sys/types.h>
6 #include <sys/stat.h>
5 #include <stdio.h> 7 #include <stdio.h>
6 #include <stdlib.h> 8 #include <stdlib.h>
7 #include <unistd.h> 9 #include <unistd.h>
8 10
9 int main(int argc, char ** argv) { 11 int main(int argc, char ** argv) {
10 int i = fork(); 12 int i = fork();
11 if (i < 0) { 13 if (i < 0) {
12 printf("fork error"); 14 printf("fork error");
13 return 1; 15 return 1;
14 } 16 }
15 if (i > 0) 17 if (i > 0)
16 return 0; 18 return 0;
17 19
18 /* child (daemon) continues */ 20 /* child (daemon) continues */
19 int j; 21 int j;
20 for (j = 0; j < getdtablesize(); j++) 22 for (j = 0; j < getdtablesize(); j++)
21 close(j); 23 close(j);
22 24
23 setsid(); /* obtain a new process group */ 25 setsid(); /* obtain a new process group */
24 26
25 while (1) { 27 while (1) {
26 system("touch /sdcard/host_heartbeat");
27 sleep(120); 28 sleep(120);
28 if (fopen("/sdcard/host_heartbeat", "r") != NULL) { 29
29 // File exists, was not removed from host. 30 struct stat ft;
31 time_t ct;
navabi 2013/03/27 22:05:29 Declare these at the top of the method instead of
Siva Chandra 2013/03/27 22:13:43 Done.
32 stat("/sdcard/host_heartbeat", &ft);
33 time(&ct);
34 if (ct - ft.st_mtime > 120) {
35 /* File was not touched for some time. */
30 system("stop adbd"); 36 system("stop adbd");
31 system("sleep 2"); 37 system("sleep 2");
32 system("start adbd"); 38 system("start adbd");
33 } 39 }
34 } 40 }
35 41
36 return 0; 42 return 0;
37 } 43 }
OLDNEW
« build/android/host_heartbeat.py ('K') | « build/android/provision_devices.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698