Changeset cd63d58
- Timestamp:
- 2008-06-29T12:47:39Z (16 years ago)
- Branches:
- master
- Children:
- f5d1b31
- Parents:
- 1145964
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
bitlbee.c
r1145964 rcd63d58 118 118 119 119 if( global.conf->runmode == RUNMODE_FORKDAEMON ) 120 ipc_master_load_state( );120 ipc_master_load_state( getenv( "_BITLBEE_RESTART_STATE" ) ); 121 121 122 122 if( global.conf->runmode == RUNMODE_DAEMON || global.conf->runmode == RUNMODE_FORKDAEMON ) -
conf.c
r1145964 rcd63d58 78 78 } 79 79 80 while( argc > 0 && ( opt = getopt( argc, argv, "i:p:P:nvIDFc:d:h R:u:" ) ) >= 0 )80 while( argc > 0 && ( opt = getopt( argc, argv, "i:p:P:nvIDFc:d:hu:" ) ) >= 0 ) 81 81 /* ^^^^ Just to make sure we skip this step from the REHASH handler. */ 82 82 { … … 145 145 " -h Show this help page.\n" ); 146 146 return NULL; 147 }148 else if( opt == 'R' )149 {150 /* We can't load the statefile yet (and should make very sure we do this151 only once), so set the filename here and load the state information152 when initializing ForkDaemon. (This option only makes sense in that153 mode anyway!) */154 ipc_master_set_statefile( optarg );155 147 } 156 148 else if( opt == 'u' ) -
ipc.c
r1145964 rcd63d58 33 33 34 34 GSList *child_list = NULL; 35 static char *statefile = NULL;36 35 37 36 static void ipc_master_cmd_client( irc_t *data, char **cmd ) … … 501 500 } 502 501 503 void ipc_master_set_statefile( char *fn )504 {505 statefile = g_strdup( fn );506 }507 508 502 509 503 static gboolean new_ipc_client( gpointer data, gint serversock, b_input_condition cond ) … … 566 560 #endif 567 561 568 int ipc_master_load_state( )562 int ipc_master_load_state( char *statefile ) 569 563 { 570 564 struct bitlbee_child *child; … … 574 568 if( statefile == NULL ) 575 569 return 0; 570 576 571 fp = fopen( statefile, "r" ); 577 572 unlink( statefile ); /* Why do it later? :-) */ -
ipc.h
r1145964 rcd63d58 58 58 59 59 char *ipc_master_save_state(); 60 void ipc_master_set_statefile( char *fn ); 61 int ipc_master_load_state(); 60 int ipc_master_load_state( char *statefile ); 62 61 int ipc_master_listen_socket(); 63 62 -
unix.c
r1145964 rcd63d58 40 40 static void sighandler( int signal ); 41 41 42 int main( int argc, char *argv[] , char **envp)42 int main( int argc, char *argv[] ) 43 43 { 44 44 int i = 0; … … 135 135 { 136 136 char *fn = ipc_master_save_state(); 137 char **args;138 int n, i;139 137 140 138 chdir( old_cwd ); 141 139 142 n = 0; 143 args = g_new0( char *, argc + 3 ); 144 args[n++] = argv[0]; 145 if( fn ) 146 { 147 args[n++] = "-R"; 148 args[n++] = fn; 149 } 150 for( i = 1; argv[i] && i < argc; i ++ ) 151 { 152 if( strcmp( argv[i], "-R" ) == 0 ) 153 i += 2; 154 155 args[n++] = argv[i]; 156 } 140 setenv( "_BITLBEE_RESTART_STATE", fn, 1 ); 141 g_free( fn ); 157 142 158 143 close( global.listen_socket ); 159 144 160 execve( args[0], args, envp ); 145 if( execv( argv[0], argv ) == -1 ) 146 /* Apparently the execve() failed, so let's just 147 jump back into our own/current main(). */ 148 /* Need more cleanup code to make this work. */ 149 return 1; /* main( argc, argv ); */ 161 150 } 162 151
Note: See TracChangeset
for help on using the changeset viewer.