Changeset 10658


Ignore:
Timestamp:
May 18, 2010, 8:58:12 PM (11 years ago)
Author:
charles
Message:

(trunk daemon) #3206 "add pidfile support" -- tweak to r10655 suggested by Longinus00: if the pidfile was successfully created, remove it on exit

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/daemon/daemon.c

    r10656 r10658  
    310310    dtr_watchdir * watchdir = NULL;
    311311    FILE * logfile = NULL;
     312    tr_bool pidfile_created = FALSE;
    312313
    313314    signal( SIGINT, gotsig );
     
    443444    tr_sessionSaveSettings( mySession, configDir, &settings );
    444445
    445     if( pid_filename != NULL ) {
     446    if( pid_filename != NULL )
     447    {
    446448        FILE * fp = fopen( pid_filename, "w+" );
    447         if( fp != NULL ) {
     449        if( fp != NULL )
     450        {
    448451            fprintf( fp, "%d", (int)getpid() );
    449452            fclose( fp );
     453            pidfile_created = TRUE;
    450454        }
    451455    }
     
    507511
    508512    /* cleanup */
     513    if( pidfile_created )
     514        remove( pid_filename );
    509515    tr_bencFree( &settings );
    510516    return 0;
Note: See TracChangeset for help on using the changeset viewer.