Changeset 1957

Show
Ignore:
Timestamp:
08/21/2007 05:40:03 PM (14 months ago)
Author:
jan
Message:

added sending UID and PID for SIGTERM and SIGINT to the logs

Location:
branches/lighttpd-1.4.x
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • branches/lighttpd-1.4.x/NEWS

    r1948 r1957  
    66- 1.4.17 - 
    77  * added dir-listing.set-footer in mod_dirlisting (#1277) 
     8  * added sending UID and PID for SIGTERM and SIGINT to the logs 
    89  * fixed hardcoded font-sizes in mod_dirlisting (#1267) 
    910  * fixed different ETag length on 32/64 platforms (#1279) 
  • branches/lighttpd-1.4.x/src/log.c

    r1371 r1957  
    127127        } 
    128128 
    129         log_error_write(srv, __FILE__, __LINE__, "s", "logfiles cycled"); 
    130  
    131129        return 0; 
    132130} 
    133131 
    134132int log_error_close(server *srv) { 
    135         log_error_write(srv, __FILE__, __LINE__, "s", "server stopped"); 
    136  
    137133        switch(srv->errorlog_mode) { 
    138134        case ERRORLOG_FILE: 
  • branches/lighttpd-1.4.x/src/server.c

    r1873 r1957  
    7171 
    7272#if defined(HAVE_SIGACTION) && defined(SA_SIGINFO) 
     73static volatile siginfo_t last_sigterm_info; 
     74static volatile siginfo_t last_sighup_info; 
     75 
    7376static void sigaction_handler(int sig, siginfo_t *si, void *context) { 
    74         UNUSED(si); 
    7577        UNUSED(context); 
    7678 
    7779        switch (sig) { 
    78         case SIGTERM: srv_shutdown = 1; break; 
     80        case SIGTERM: 
     81                srv_shutdown = 1; 
     82                memcpy(&last_sigterm_info, si, sizeof(*si)); 
     83                break; 
    7984        case SIGINT: 
    80              if (graceful_shutdown) srv_shutdown = 1; 
    81              else graceful_shutdown = 1; 
    82  
    83              break; 
    84         case SIGALRM: handle_sig_alarm = 1; break; 
    85         case SIGHUP:  handle_sig_hup = 1; break; 
    86         case SIGCHLD: break; 
     85                if (graceful_shutdown) { 
     86                        srv_shutdown = 1; 
     87                } else { 
     88                        graceful_shutdown = 1; 
     89                } 
     90                memcpy(&last_sigterm_info, si, sizeof(*si)); 
     91 
     92                break; 
     93        case SIGALRM:  
     94                handle_sig_alarm = 1;  
     95                break; 
     96        case SIGHUP: 
     97                handle_sig_hup = 1; 
     98                memcpy(&last_sighup_info, si, sizeof(*si)); 
     99                break; 
     100        case SIGCHLD: 
     101                break; 
    87102        } 
    88103} 
     
    10801095 
    10811096                                return -1; 
     1097                        } else { 
     1098#ifdef HAVE_SIGACTION 
     1099                                log_error_write(srv, __FILE__, __LINE__, "sdsd",  
     1100                                        "logfiles cycled UID =", 
     1101                                        last_sigterm_info.si_uid, 
     1102                                        "PID =", 
     1103                                        last_sigterm_info.si_pid); 
     1104#else 
     1105                                log_error_write(srv, __FILE__, __LINE__, "s",  
     1106                                        "logfiles cycled"); 
     1107#endif 
    10821108                        } 
    10831109                } 
     
    13791405        } 
    13801406 
     1407#ifdef HAVE_SIGACTION 
     1408        log_error_write(srv, __FILE__, __LINE__, "sdsd",  
     1409                        "server stopped by UID =", 
     1410                        last_sigterm_info.si_uid, 
     1411                        "PID =", 
     1412                        last_sigterm_info.si_pid); 
     1413#else 
     1414        log_error_write(srv, __FILE__, __LINE__, "s",  
     1415                        "server stopped"); 
     1416#endif 
     1417 
    13811418        /* clean-up */ 
    13821419        log_error_close(srv);