IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 26782


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:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20091201/Ohana

  • branches/eam_branches/20091201/Ohana/src/opihi/include/pclient.h

    r21153 r26782  
    5252void FreePclient (void);
    5353void gotsignal (int signum);
     54void pipe_signal (int signum);
     55void pipe_signal_clear(void);
    5456
    5557# define DTIME(A,B) ((A.tv_sec - B.tv_sec) + 1e-6*(A.tv_usec - B.tv_usec))
  • branches/eam_branches/20091201/Ohana/src/opihi/pclient/ChildOps.c

    r26257 r26782  
    11# include "pclient.h"
    2 #include <sys/ioctl.h>
    3 #include <sys/types.h>
    4 #include <unistd.h>
     2# include <sys/ioctl.h>
     3# include <sys/types.h>
     4# include <unistd.h>
    55// #include <stropts.h>
    66
     
    6767    case 0:   /* pipe is closed */
    6868      /** change child state? **/
     69      pipe_signal_clear();
    6970      break;
    7071    default:  /* data in pipe */
     
    8182    case 0:   /* pipe is closed */
    8283      /** change child state? **/
     84      pipe_signal_clear();
    8385      break;
    8486    default:  /* data in pipe */
  • 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.