IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 5, 2010, 1:20:45 PM (16 years ago)
Author:
eugene
Message:

gracefully exit pclient if pcontrol dies and raised a PIPE signal, but keep running if it is the pclient child process that died

Location:
branches/eam_branches/20091201/Ohana
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20091201/Ohana

  • branches/eam_branches/20091201/Ohana/src/opihi/pclient/pclient.c.in

    r18123 r26782  
    4646
    4747  /* ignore the history file.  to change this, see, eg, mana.c */
    48   signal (SIGPIPE, gotsignal);
     48
     49  /* We do not want pclient to exit just because the connection to the
     50     child process is broken.  However, if the connection to the parent
     51     process is broken, we should exit.  To handle this, we define
     52     pipe_signal() which tracks the number of times it has been called.
     53     Every time an I/O operation on the child file descriptor raises this signal,
     54     we need to manage the crashed child and then clear the count.  Signals raised by
     55     I/O to the parent do not result in clearing the count.  If the count passes a maximum,
     56     we exit pclient */
     57     
     58  signal (SIGPIPE, pipe_signal);
    4959  signal (SIGTSTP, gotsignal);
    5060  signal (SIGTTIN, gotsignal);
     
    6777}
    6878
     79static int Npipe = 0;
     80
     81void pipe_signal (int signum) {
     82  Npipe ++;
     83  if (Npipe > 100) {
     84    exit (5);
     85  }
     86  gprint (GP_ERR, "closed pipe : did child process exit unexpectedly?\n");
     87  return;
     88}
     89
     90void pipe_signal_clear(void) {
     91  Npipe = 0;
     92}
     93
    6994void gotsignal (int signum) {
    7095  gprint (GP_ERR, "got signal : %d\n", signum);
Note: See TracChangeset for help on using the changeset viewer.