Changeset 4762 for trunk/Ohana/src/opihi/pclient/reset.c
- Timestamp:
- Aug 13, 2005, 10:30:13 AM (21 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/pclient/reset.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/pclient/reset.c
r4689 r4762 4 4 5 5 int i, result, waitstatus; 6 struct timespec request, remain; 6 7 7 8 if (argc != 1) { 8 9 fprintf (stderr, "USAGE: reset\n"); 9 fprintf ( stdout, "STATUS -1\n");10 fprintf (GetOutfile(), "STATUS -1\n"); 10 11 return (FALSE); 11 12 } … … 13 14 if (ChildStatus == PCLIENT_NONE) { 14 15 fprintf (stderr, "no child process, cannot reset\n"); 15 fprintf ( stdout, "STATUS 2\n");16 fprintf (GetOutfile(), "STATUS 2\n"); 16 17 return (TRUE); 17 18 } 18 19 20 /* avoid blocking on waitpid, test every 100 usec, up to 50 msec */ 21 request.tv_sec = 0; 22 request.tv_nsec = 100000; 23 19 24 if (ChildStatus == PCLIENT_BUSY) { 20 /* send SIGTERM signal to job */25 /* job is still running, send SIGTERM signal to job */ 21 26 kill (ChildPID, SIGTERM); 22 result = 0;23 for (i = 0; (i < 10) && (result == 0); i++) {24 usleep (10000); /* 10 ms is min */27 result = waitpid (ChildPID, &waitstatus, WNOHANG); 28 for (i = 0; (i < 500) && (result == 0); i++) { 29 nanosleep (&request, &remain); 25 30 result = waitpid (ChildPID, &waitstatus, WNOHANG); 26 31 } 27 32 if (result) goto reset_job; 28 33 29 /* send SIGTERMsignal to job */34 /* job did not exit, send SIGKILL signal to job */ 30 35 kill (ChildPID, SIGKILL); 31 result = 0;32 for (i = 0; (i < 10) && (result == 0); i++) {33 usleep (10000); /* 10 ms is min */36 result = waitpid (ChildPID, &waitstatus, WNOHANG); 37 for (i = 0; (i < 500) && (result == 0); i++) { 38 nanosleep (&request, &remain); 34 39 result = waitpid (ChildPID, &waitstatus, WNOHANG); 35 40 } … … 38 43 /* total failure, don't reset */ 39 44 fprintf (stderr, "child process %d is hung, cannot reset\n", ChildPID); 40 fprintf ( stdout, "STATUS 0\n");45 fprintf (GetOutfile(), "STATUS 0\n"); 41 46 return (FALSE); 42 47 } … … 57 62 ChildExitStatus = 0; 58 63 59 fprintf ( stdout, "STATUS 1\n");64 fprintf (GetOutfile(), "STATUS 1\n"); 60 65 return (TRUE); 61 66 } … … 68 73 */ 69 74 75 /* the linux kernel timer sticks in a 10ms lag between kill and the harvest */
Note:
See TracChangeset
for help on using the changeset viewer.
