Ignore:
Timestamp:
22/05/06 16:20:12 (14 years ago)
Author:
spascoe
Message:

Got bbftpd_private_finalise working by setting a SIGTERM signal handler.
This is confirmed by running the test suite and examining /var/log/messages.

Location:
TI05-delivery/trunk/src/bbftp-server-3.2.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • TI05-delivery/trunk/src/bbftp-server-3.2.0/bbftpd/bbftpd_private.c

    r973 r975  
    5555#include <version.h> 
    5656 
     57#ifdef NDG_AUTH 
     58#include <signal.h> 
     59#endif // NDG_AUTH 
     60 
    5761extern  int     incontrolsock ; 
    5862extern  int     outcontrolsock ; 
     
    358362*/ 
    359363int bbftpd_private_initialise(char *logmessage) { 
    360  
    361     if (atexit(bbftpd_private_atexit) != 0) { 
    362       sprintf(logmessage, "atexit failure"); 
    363       return -1; 
    364     } 
    365     ndg_atexit_status = NDG_INFATHER; 
    366     return bbftpd_private_init(logmessage); 
    367 } 
     364  struct sigaction sga; 
     365 
     366  /* Set signal handlers for the daemon. 
     367   */ 
     368  sga.sa_handler = bbftpd_private_sigaction ; 
     369  sigemptyset(&(sga.sa_mask)); 
     370  sga.sa_flags = 0  ; 
     371  if ( sigaction(SIGTERM,&sga,0) < 0 ) { 
     372    syslog(BBFTPD_ERR,"Error sigaction SIGCTERM : %s",strerror(errno)) ; 
     373    return -1; 
     374  } 
     375 
     376 
     377  if (atexit(bbftpd_private_atexit) != 0) { 
     378    sprintf(logmessage, "atexit failure"); 
     379    return -1; 
     380  } 
     381  ndg_atexit_status = NDG_INFATHER; 
     382  return bbftpd_private_init(logmessage); 
     383} 
     384 
     385/* 
     386** bbftpd_private_sigaction(int sig) 
     387** 
     388**      Routine to exit gracefully if SIGTERM is sent.  The daemon process 
     389**      will not call any atexit() functions on receipt of SIGTERM by default. 
     390**      This function is a signal handler to change this behaviour. 
     391*/ 
     392void bbftpd_private_sigaction(int sig) 
     393{ 
     394  // Hopefully calling atexit() handlers. 
     395  exit(0); 
     396} 
     397 
    368398 
    369399/* 
  • TI05-delivery/trunk/src/bbftp-server-3.2.0/includes/daemon_proto.h

    r973 r975  
    6565#ifdef NDG_AUTH 
    6666int bbftpd_private_initialise(char *logmessage); 
     67void bbftpd_private_sigaction(int sig); 
    6768void bbftpd_private_atexit(void); 
    6869#endif // NDG_AUTH 
Note: See TracChangeset for help on using the changeset viewer.