Changeset 34b17d9


Ignore:
Timestamp:
2006-02-02T13:21:44Z (18 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
1d2e3c2
Parents:
8365610
Message:

Added PID-file code.

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • bitlbee.c

    r8365610 r34b17d9  
    4545        int i;
    4646        GIOChannel *ch;
     47        FILE *fp;
    4748       
    4849        log_link( LOGLVL_ERROR, LOGOUTPUT_SYSLOG );
     
    111112#endif
    112113       
     114        if( ( fp = fopen( global.conf->pidfile, "w" ) ) )
     115        {
     116                fprintf( fp, "%d\n", (int) getpid() );
     117                fclose( fp );
     118        }
     119        else
     120        {
     121                log_message( LOGLVL_WARNING, "Warning: Couldn't write PID to `%s'", global.conf->pidfile );
     122        }
     123       
    113124        return( 0 );
    114125}
  • conf.c

    r8365610 r34b17d9  
    6161        conf->configdir = g_strdup( CONFIG );
    6262        conf->plugindir = g_strdup( PLUGINDIR );
     63        conf->pidfile = g_strdup( "/var/run/bitlbee.pid" );
    6364        conf->motdfile = g_strdup( ETCDIR "/motd.txt" );
    6465        conf->ping_interval = 180;
     
    7778        }
    7879       
    79         while( argc > 0 && ( opt = getopt( argc, argv, "i:p:nvIDFc:d:h" ) ) >= 0 )
     80        while( argc > 0 && ( opt = getopt( argc, argv, "i:p:P:nvIDFc:d:h" ) ) >= 0 )
    8081        /*     ^^^^ Just to make sure we skip this step from the REHASH handler. */
    8182        {
     
    9293                        }
    9394                        conf->port = i;
     95                }
     96                else if( opt == 'p' )
     97                {
     98                        g_free( conf->pidfile );
     99                        conf->pidfile = g_strdup( optarg );
    94100                }
    95101                else if( opt == 'n' )
     
    175181                                else
    176182                                        conf->runmode = RUNMODE_INETD;
     183                        }
     184                        else if( g_strcasecmp( ini->key, "pidfile" ) == 0 )
     185                        {
     186                                g_free( conf->pidfile );
     187                                conf->pidfile = g_strdup( ini->value );
    177188                        }
    178189                        else if( g_strcasecmp( ini->key, "daemoninterface" ) == 0 )
  • conf.h

    r8365610 r34b17d9  
    4343        char *configdir;
    4444        char *plugindir;
     45        char *pidfile;
    4546        char *motdfile;
    4647        char *primary_storage;
  • configure

    r8365610 r34b17d9  
    1414datadir='$prefix/share/bitlbee/'
    1515config='/var/lib/bitlbee/'
     16pidfile='/var/run/bitlbee.pid'
    1617plugindir='$prefix/lib/bitlbee'
    1718
     
    4647--datadir=...                                           $datadir
    4748--plugindir=...                                         $plugindir
     49--pidfile=...                                           $pidfile
    4850--config=...                                            $config
    4951
     
    7476config=`eval echo "$config/" | sed 's/\/\{1,\}/\//g'`
    7577plugindir=`eval echo "$plugindir/" | sed 's/\/\{1,\}/\//g'`
     78pidfile=`eval echo "$pidfile/" | sed 's/\/\{1,\}/\//g'`
    7679
    7780cat<<EOF>Makefile.settings
     
    8386DATADIR=$datadir
    8487PLUGINDIR=$plugindir
     88PIDFILE=$pidfile
    8589CONFIG=$config
    8690
     
    104108#define VARDIR "$datadir"
    105109#define PLUGINDIR "$plugindir"
     110#define PIDFILE "$pidfile"
    106111#define ARCH "$arch"
    107112#define CPU "$cpu"
Note: See TracChangeset for help on using the changeset viewer.