IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 31, 2005, 8:04:11 AM (21 years ago)
Author:
eugene
Message:

task/job list cleanup, fixing kill/delete

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/pantasks/LocalJob.c

    r4602 r4684  
    102102  int result, waitstatus;
    103103
     104  fprintf (stderr, "checking on %d\n", job[0].pid);
     105
    104106  /* check local job status */
    105107  result = waitpid (job[0].pid, &waitstatus, WNOHANG);
     
    135137        exit (1);
    136138      }
     139      fprintf (stderr, "waited for %d\n", result);
    137140     
    138141      if (WIFEXITED(waitstatus)) {
     
    151154  return;
    152155}
     156
     157int KillLocalJob (Job *job) {
     158
     159  int i, result, waitstatus;
     160
     161  if (job[0].state != JOB_BUSY) return (TRUE);
     162
     163  /* send SIGTERM signal to job */
     164  kill (job[0].pid, SIGTERM);
     165  result = 0;
     166  for (i = 0; (i < 10) && (result == 0); i++) {
     167    usleep (10000);  /* 10 ms is min */
     168    result = waitpid (job[0].pid, &waitstatus, WNOHANG);
     169  }
     170  if (result) return (TRUE);
     171
     172  /* send SIGKILL signal to job */
     173  kill (job[0].pid, SIGKILL);
     174  result = 0;
     175  for (i = 0; (i < 10) && (result == 0); i++) {
     176    usleep (10000);  /* 10 ms is min */
     177    result = waitpid (job[0].pid, &waitstatus, WNOHANG);
     178  }
     179  if (result) return (TRUE);
     180
     181  /* total failure, don't reset */
     182  return (FALSE);
     183}
     184
Note: See TracChangeset for help on using the changeset viewer.