mirror of
https://github.com/transmission/transmission
synced 2025-01-31 11:23:40 +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 );
|
errsyslog( 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( NULL != pidfile && 0 > savepid( pidfile ) )
|
|
||||||
exit( 1 );
|
|
||||||
atexit( exitcleanup );
|
atexit( exitcleanup );
|
||||||
sockfd = trylocksock( sockpath );
|
sockfd = trylocksock( sockpath );
|
||||||
if( 0 > sockfd )
|
if( 0 > sockfd )
|
||||||
{
|
{
|
||||||
exit( 1 );
|
exit( 1 );
|
||||||
}
|
}
|
||||||
|
if( NULL != pidfile && 0 > savepid( pidfile ) )
|
||||||
|
{
|
||||||
|
exit( 1 );
|
||||||
|
}
|
||||||
|
|
||||||
evbase = event_init();
|
evbase = event_init();
|
||||||
setupsigs( evbase );
|
setupsigs( evbase );
|
||||||
|
@ -299,15 +301,15 @@ exitcleanup( void )
|
||||||
unlink( gl_sockpath );
|
unlink( gl_sockpath );
|
||||||
close( gl_sockfd );
|
close( gl_sockfd );
|
||||||
}
|
}
|
||||||
|
if( 0 != gl_pidfile[0] )
|
||||||
|
{
|
||||||
|
unlink( gl_pidfile );
|
||||||
|
}
|
||||||
if( 0 <= gl_lockfd )
|
if( 0 <= gl_lockfd )
|
||||||
{
|
{
|
||||||
unlink( gl_lockpath );
|
unlink( gl_lockpath );
|
||||||
close( gl_lockfd );
|
close( gl_lockfd );
|
||||||
}
|
}
|
||||||
if( 0 != gl_pidfile[0] )
|
|
||||||
{
|
|
||||||
unlink( gl_pidfile );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in a new issue