- Timestamp:
- 2005-12-26T14:02:47Z (19 years ago)
- Branches:
- master
- Children:
- 238f828
- Parents:
- ffea9b9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
unix.c
rffea9b9 rd25f6fc 32 32 #include <unistd.h> 33 33 #include <sys/time.h> 34 #include <sys/wait.h> 34 35 35 36 global_t global; /* Against global namespace pollution */ … … 46 47 global.loop = g_main_new( FALSE ); 47 48 48 log_init( 49 log_init(); 49 50 50 51 nogaim_init(); … … 70 71 log_message( LOGLVL_INFO, "Bitlbee %s starting in daemon mode.", BITLBEE_VERSION ); 71 72 } 73 else if( global.conf->runmode == RUNMODE_FORKDAEMON ) 74 { 75 i = bitlbee_daemon_init(); 76 log_message( LOGLVL_INFO, "Bitlbee %s starting in forking daemon mode.", BITLBEE_VERSION ); 77 } 72 78 if( i != 0 ) 73 79 return( i ); 74 80 75 global.storage = storage_init( global.conf->primary_storage, 76 global.conf->migrate_storage ); 81 global.storage = storage_init( global.conf->primary_storage, global.conf->migrate_storage ); 77 82 if ( global.storage == NULL) { 78 83 log_message( LOGLVL_ERROR, "Unable to load storage backend '%s'", global.conf->primary_storage ); … … 84 89 memset( &sig, 0, sizeof( sig ) ); 85 90 sig.sa_handler = sighandler; 91 sigaction( SIGCHLD, &sig, &old ); 86 92 sigaction( SIGPIPE, &sig, &old ); 87 93 sig.sa_flags = SA_RESETHAND; … … 107 113 static void sighandler( int signal ) 108 114 { 109 /* FIXME: In fact, calling log_message() here can be dangerous. But well, let's take the risk for now.*/115 /* FIXME: Calling log_message() here is not a very good idea! */ 110 116 111 117 if( signal == SIGTERM ) … … 133 139 } 134 140 } 141 else if( signal == SIGCHLD ) 142 { 143 pid_t pid; 144 int st; 145 146 while( ( pid = waitpid( 0, &st, WNOHANG ) ) > 0 ) 147 { 148 if( WIFSIGNALED( st ) ) 149 log_message( LOGLVL_INFO, "Client %d terminated normally. (status = %d)", pid, WEXITSTATUS( st ) ); 150 else if( WIFEXITED( st ) ) 151 log_message( LOGLVL_INFO, "Client %d killed by signal %d.", pid, WTERMSIG( st ) ); 152 } 153 } 135 154 else if( signal != SIGPIPE ) 136 155 {
Note: See TracChangeset
for help on using the changeset viewer.