Example #1
0
/*
 * sets up the logging pipe and forks off the logger process 
 */
void startLogging(int level, int thread) {

  // if we're a client, just open the log and
  // don't start a logger.
  if (! thread ) {
     OPENLOG(level);
    return;
  }
    
  pipe(logfds);
  int             lpid;

  lpid = fork();

  if (lpid == 0) {
    close(logfds[1]);           /* close write end */
    setSignal(SIGINT, SIG_IGN, 0);
    setSignal(SIGTERM, SIG_IGN, 0);
    setSignal(SIGHUP, SIG_IGN, 0);

    runLogger(logfds[0], level);

    close(logfds[0]);
    exit(0);
  } else if (lpid > 0) {
    close(logfds[0]);           /* close read end */
    log_w_stream = fdopen(logfds[1], "w");
    return;
  } else {
    fprintf(stderr, "*** fork of logger proc failed\n");
    abort();
  }
}
Example #2
0
/*
 * sets up the logging pipe and forks off the logger process 
 */
void
startLogging(int level, int thread)
{
  // if we're a client, just open the log and
  // don't start a logger.
  if (! thread ) {
    OPENLOG(level);
    return;
  }

  pipe(logfds);
  int             lpid;
  lpid = fork();

  if (lpid == 0) {
    close(logfds[1]);           /* close write end */
    setSignal(SIGINT, SIG_IGN, 0);
    setSignal(SIGTERM, SIG_IGN, 0);
    setSignal(SIGHUP, SIG_IGN, 0);
    setSignal(SIGUSR2, SIG_IGN, 0);

    /* Label the process by modifying the cmdline */
    extern void append2Argv(char *appendstr);
    extern unsigned int labelProcs;
    if (labelProcs) {
      append2Argv("-proc:Logger");
    }

    runLogger(logfds[0], level);

    close(logfds[0]);
    exit(0);
  } else if (lpid > 0) {
    close(logfds[0]);           /* close read end */
    log_w_stream = fdopen(logfds[1], "w");
    return;
  } else {
    fprintf(stderr, "*** fork of logger proc failed\n");
    abort();
  }
}