Changeset 10655


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

(trunk daemon) add pidfile support to transmission-daemon

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/daemon/daemon.c

    r10646 r10655  
    4444static tr_bool closing = FALSE;
    4545static tr_session * mySession = NULL;
     46static const char * pid_filename = NULL;
    4647
    4748/***
     
    101102    { 953, "global-seedratio", "All torrents, unless overridden by a per-torrent setting, should seed until a specific ratio", "gsr", 1, "ratio" },
    102103    { 954, "no-global-seedratio", "All torrents, unless overridden by a per-torrent setting, should seed regardless of ratio", "GSR", 0, NULL },
     104    { 'x', "pid-file", "Enable PID file", "x", 1, "<pid-file>" },
    103105    { 0, NULL, NULL, NULL, 0, NULL }
    104106};
     
    402404                      tr_bencDictAddStr( &settings, TR_PREFS_KEY_RPC_BIND_ADDRESS, optarg );
    403405                      break;
    404             case 953:
    405                       tr_bencDictAddReal( &settings, TR_PREFS_KEY_RATIO, atof(optarg) );
    406                       tr_bencDictAddBool( &settings, TR_PREFS_KEY_RATIO_ENABLED, TRUE );
    407                       break;
    408             case 954:
    409                       tr_bencDictAddBool( &settings, TR_PREFS_KEY_RATIO_ENABLED, FALSE );
    410                       break;
    411             case 'y': tr_bencDictAddBool( &settings, TR_PREFS_KEY_LPD_ENABLED, TRUE );
    412                       break;
    413             case 'Y': tr_bencDictAddBool( &settings, TR_PREFS_KEY_LPD_ENABLED, FALSE );
    414                       break;
     406            case 953:
     407                      tr_bencDictAddReal( &settings, TR_PREFS_KEY_RATIO, atof(optarg) );
     408                      tr_bencDictAddBool( &settings, TR_PREFS_KEY_RATIO_ENABLED, TRUE );
     409                      break;
     410            case 954:
     411                      tr_bencDictAddBool( &settings, TR_PREFS_KEY_RATIO_ENABLED, FALSE );
     412                      break;
     413            case 'x': pid_filename = optarg;
     414                      break;
     415            case 'y': tr_bencDictAddBool( &settings, TR_PREFS_KEY_LPD_ENABLED, TRUE );
     416                      break;
     417            case 'Y': tr_bencDictAddBool( &settings, TR_PREFS_KEY_LPD_ENABLED, FALSE );
     418                      break;
    415419            default:  showUsage( );
    416420                      break;
     
    447451    tr_ninf( NULL, "Using settings from \"%s\"", configDir );
    448452    tr_sessionSaveSettings( mySession, configDir, &settings );
     453
     454    if( pid_filename != NULL ) {
     455        FILE * fp = fopen( pid_filename, "w+" );
     456        if( fp != NULL ) {
     457            fprintf( fp, "%d", (int)getpid() );
     458            fclose( fp );
     459        }
     460    }
    449461
    450462    if( tr_bencDictFindBool( &settings, TR_PREFS_KEY_RPC_AUTH_REQUIRED, &boolVal ) && boolVal )
     
    479491#ifdef HAVE_SYSLOG
    480492    if( !foreground )
    481         openlog( MY_NAME, LOG_CONS, LOG_DAEMON );
     493        openlog( MY_NAME, LOG_CONS|LOG_PID, LOG_DAEMON );
    482494#endif
    483495
Note: See TracChangeset for help on using the changeset viewer.