/*The following definitions come from util.c */
+int sig_usr2(void);
+int sig_usr1(void);
void setup_logging(char *pname,BOOL interactive);
void reopen_logs(void);
char *tmpdir(void);
static char *filename_dos(char *path,char *buf);
+#if defined(SIGUSR2)
+/**************************************************************************** **
+ catch a sigusr2 - decrease the debug log level.
+ **************************************************************************** */
+int sig_usr2(void)
+{
+ BlockSignals( True, SIGUSR2);
+
+ DEBUGLEVEL--;
+
+ if(DEBUGLEVEL < 0)
+ DEBUGLEVEL = 0;
+
+ DEBUG( 0, ( "Got SIGUSR2 set debug level to %d.\n", DEBUGLEVEL ) );
+
+ BlockSignals( False, SIGUSR2);
+#ifndef DONT_REINSTALL_SIG
+ signal(SIGUSR2, SIGNAL_CAST sig_usr2);
+#endif
+ return(0);
+}
+#endif /* SIGUSR1 */
+
+#if defined(SIGUSR1)
+/**************************************************************************** **
+ catch a sigusr1 - increase the debug log level.
+ **************************************************************************** */
+int sig_usr1(void)
+{
+ BlockSignals( True, SIGUSR1);
+
+ DEBUGLEVEL++;
+
+ if(DEBUGLEVEL > 10)
+ DEBUGLEVEL = 10;
+
+ DEBUG( 0, ( "Got SIGUSR1 set debug level to %d.\n", DEBUGLEVEL ) );
+
+ BlockSignals( False, SIGUSR1);
+#ifndef DONT_REINSTALL_SIG
+ signal(SIGUSR1, SIGNAL_CAST sig_usr1);
+#endif
+ return(0);
+}
+#endif /* SIGUSR1 */
+
+
/*******************************************************************
get ready for syslog stuff
******************************************************************/
announce_my_servers_removed();
exit(0);
+
/* Keep compiler happy.. */
return 0;
} /* sig_term */
-
/**************************************************************************** **
catch a sighup
**************************************************************************** */
signal( SIGHUP, SIGNAL_CAST sig_hup );
signal( SIGTERM, SIGNAL_CAST sig_term );
+ /* Setup the signals that allow the debug log level
+ to by dynamically changed. */
+
+#if defined(SIGUSR1)
+ signal( SIGUSR1, SIGNAL_CAST sig_usr1 );
+#endif /* SIGUSR1 */
+
+#if defined(SIGUSR2)
+ signal( SIGUSR2, SIGNAL_CAST sig_usr2 );
+#endif /* SIGUSR2 */
+
while((opt = getopt(argc, argv, "as:T:I:C:bAi:B:N:Rn:l:d:Dp:hSH:G:f:")) != EOF)
{
switch (opt)
exit(1);
}
- /* We can only take sigterm signals in the select. */
+ /* We can only take signals in the select. */
BlockSignals( True, SIGTERM );
+#if defined(SIGUSR1)
+ BlockSignals( True, SIGUSR1);
+#endif /* SIGUSR1 */
+#if defined(SIGUSR2)
+ BlockSignals( True, SIGUSR2);
+#endif /* SIGUSR2 */
process();
close_sockets();
timeout.tv_sec = (run_election||num_response_packets) ? 1 : NMBD_SELECT_LOOP;
timeout.tv_usec = 0;
- /* We can only take term signals when we are in the select. */
+ /* Prepare for the select - allow certain signals. */
+
BlockSignals(False, SIGTERM);
+#if defined(SIGUSR1)
+ BlockSignals(False, SIGUSR1);
+#endif /* SIGUSR1 */
+#if defined(SIGUSR2)
+ BlockSignals(False, SIGUSR2);
+#endif /* SIGUSR2 */
+
selrtn = sys_select(&fds,&timeout);
+
+ /* We can only take signals when we are in the select - block them again here. */
+
BlockSignals(True, SIGTERM);
+#if defined(SIGUSR1)
+ BlockSignals(True, SIGUSR1);
+#endif /* SIGUSR1 */
+#if defined(SIGUSR2)
+ BlockSignals(True, SIGUSR2);
+#endif /* SIGUSR2 */
if(selrtn > 0)
{
#ifndef NO_SIGNAL_TEST
signal(SIGHUP,SIGNAL_CAST sig_hup);
#endif
-
+
+ /* Setup the signals that allow the debug log level
+ to by dynamically changed. */
+
+#if defined(SIGUSR1)
+ signal( SIGUSR1, SIGNAL_CAST sig_usr1 );
+#endif /* SIGUSR1 */
+
+#if defined(SIGUSR2)
+ signal( SIGUSR2, SIGNAL_CAST sig_usr2 );
+#endif /* SIGUSR2 */
+
DEBUG(3,("%s loaded services\n",timestring()));
if (!is_daemon && !is_a_socket(0))