Changeset 8e419cb for unix.c


Ignore:
Timestamp:
2006-01-10T21:35:08Z (18 years ago)
Author:
Jelmer Vernooij <jelmer@…>
Branches:
master
Children:
a4dc9f7
Parents:
3e91c3e (diff), dd8d4c5 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge Wilmer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • unix.c

    r3e91c3e r8e419cb  
    3232#include <unistd.h>
    3333#include <sys/time.h>
     34#include <sys/wait.h>
    3435
    3536global_t global;        /* Against global namespace pollution */
     
    4647        global.loop = g_main_new( FALSE );
    4748       
    48         log_init( );
     49        log_init();
    4950
    5051        nogaim_init();
     
    7677                log_message( LOGLVL_INFO, "Bitlbee %s starting in daemon mode.", BITLBEE_VERSION );
    7778        }
     79        else if( global.conf->runmode == RUNMODE_FORKDAEMON )
     80        {
     81                i = bitlbee_daemon_init();
     82                log_message( LOGLVL_INFO, "Bitlbee %s starting in forking daemon mode.", BITLBEE_VERSION );
     83        }
    7884        if( i != 0 )
    7985                return( i );
    8086
    81         global.storage = storage_init( global.conf->primary_storage,
    82                                                                    global.conf->migrate_storage );
     87        global.storage = storage_init( global.conf->primary_storage, global.conf->migrate_storage );
    8388        if ( global.storage == NULL) {
    8489                log_message( LOGLVL_ERROR, "Unable to load storage backend '%s'", global.conf->primary_storage );
     
    9095        memset( &sig, 0, sizeof( sig ) );
    9196        sig.sa_handler = sighandler;
     97        sigaction( SIGCHLD, &sig, &old );
    9298        sigaction( SIGPIPE, &sig, &old );
    9399        sig.sa_flags = SA_RESETHAND;
     
    113119static void sighandler( int signal )
    114120{
    115         /* FIXME: In fact, calling log_message() here can be dangerous. But well, let's take the risk for now. */
     121        /* FIXME: Calling log_message() here is not a very good idea! */
    116122       
    117123        if( signal == SIGTERM )
     
    139145                }
    140146        }
     147        else if( signal == SIGCHLD )
     148        {
     149                pid_t pid;
     150                int st;
     151               
     152                while( ( pid = waitpid( 0, &st, WNOHANG ) ) > 0 )
     153                {
     154                        if( WIFSIGNALED( st ) )
     155                                log_message( LOGLVL_INFO, "Client %d terminated normally. (status = %d)", pid, WEXITSTATUS( st ) );
     156                        else if( WIFEXITED( st ) )
     157                                log_message( LOGLVL_INFO, "Client %d killed by signal %d.", pid, WTERMSIG( st ) );
     158                }
     159        }
    141160        else if( signal != SIGPIPE )
    142161        {
Note: See TracChangeset for help on using the changeset viewer.