mirror of
https://github.com/transmission/transmission
synced 2024-12-24 08:43:27 +00:00
(trunk daemon) #3206 "add pidfile support" -- tweak to r10655 suggested by Longinus00: if the pidfile was successfully created, remove it on exit
This commit is contained in:
parent
5eb2f5a274
commit
0cc65eb152
1 changed files with 8 additions and 2 deletions
|
@ -309,6 +309,7 @@ main( int argc, char ** argv )
|
|||
const char * configDir = NULL;
|
||||
dtr_watchdir * watchdir = NULL;
|
||||
FILE * logfile = NULL;
|
||||
tr_bool pidfile_created = FALSE;
|
||||
|
||||
signal( SIGINT, gotsig );
|
||||
signal( SIGTERM, gotsig );
|
||||
|
@ -442,11 +443,14 @@ main( int argc, char ** argv )
|
|||
tr_ninf( NULL, "Using settings from \"%s\"", configDir );
|
||||
tr_sessionSaveSettings( mySession, configDir, &settings );
|
||||
|
||||
if( pid_filename != NULL ) {
|
||||
if( pid_filename != NULL )
|
||||
{
|
||||
FILE * fp = fopen( pid_filename, "w+" );
|
||||
if( fp != NULL ) {
|
||||
if( fp != NULL )
|
||||
{
|
||||
fprintf( fp, "%d", (int)getpid() );
|
||||
fclose( fp );
|
||||
pidfile_created = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -506,6 +510,8 @@ main( int argc, char ** argv )
|
|||
printf( " done.\n" );
|
||||
|
||||
/* cleanup */
|
||||
if( pidfile_created )
|
||||
remove( pid_filename );
|
||||
tr_bencFree( &settings );
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue