mirror of
https://github.com/transmission/transmission
synced 2025-01-31 03:12:44 +00:00
Properly protect pidfile creation and deletion with the lockfile.
This commit is contained in:
parent
5c3d45767e
commit
571e53b7ca
1 changed files with 8 additions and 6 deletions
|
@ -85,14 +85,16 @@ main( int argc, char ** argv )
|
|||
errsyslog( 1 );
|
||||
}
|
||||
|
||||
if( NULL != pidfile && 0 > savepid( pidfile ) )
|
||||
exit( 1 );
|
||||
atexit( exitcleanup );
|
||||
sockfd = trylocksock( sockpath );
|
||||
if( 0 > sockfd )
|
||||
{
|
||||
exit( 1 );
|
||||
}
|
||||
if( NULL != pidfile && 0 > savepid( pidfile ) )
|
||||
{
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
evbase = event_init();
|
||||
setupsigs( evbase );
|
||||
|
@ -299,15 +301,15 @@ exitcleanup( void )
|
|||
unlink( gl_sockpath );
|
||||
close( gl_sockfd );
|
||||
}
|
||||
if( 0 != gl_pidfile[0] )
|
||||
{
|
||||
unlink( gl_pidfile );
|
||||
}
|
||||
if( 0 <= gl_lockfd )
|
||||
{
|
||||
unlink( gl_lockpath );
|
||||
close( gl_lockfd );
|
||||
}
|
||||
if( 0 != gl_pidfile[0] )
|
||||
{
|
||||
unlink( gl_pidfile );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in a new issue