mirror of
https://github.com/octoleo/lsyncd.git
synced 2025-01-06 00:30:46 +00:00
write pid of forked process
This commit is contained in:
parent
3f78514273
commit
544f6066b7
@ -1,6 +1,7 @@
|
||||
????-??-??: 2.2.2
|
||||
fix: checkgauge 'insist'
|
||||
fix: no partial path exlusion tests
|
||||
fix: write pid of forked process in pidfile
|
||||
|
||||
2017-01-05: 2.2.1
|
||||
enhancement: now always using filter lists with rysnc
|
||||
|
33
lsyncd.c
33
lsyncd.c
@ -677,7 +677,8 @@ non_block_fd( int fd )
|
||||
| Writes a pid file.
|
||||
*/
|
||||
static void
|
||||
write_pidfile(
|
||||
write_pidfile
|
||||
(
|
||||
lua_State *L,
|
||||
const char *pidfile
|
||||
)
|
||||
@ -970,12 +971,13 @@ user_obs_tidy( struct observance *obs )
|
||||
}
|
||||
|
||||
|
||||
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
|
||||
( Library calls for the runner )
|
||||
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
||||
/******************************.
|
||||
* Library calls for the runner *
|
||||
'******************************/
|
||||
|
||||
|
||||
static void daemonize( lua_State *L );
|
||||
static void daemonize( lua_State *L, const char *pidfile );
|
||||
|
||||
int l_stackdump( lua_State* L );
|
||||
|
||||
|
||||
@ -1612,16 +1614,11 @@ l_configure( lua_State *L )
|
||||
openlog( log_ident, 0, settings.log_facility );
|
||||
}
|
||||
|
||||
if( settings.pidfile )
|
||||
{
|
||||
write_pidfile( L, settings.pidfile );
|
||||
}
|
||||
|
||||
if( !settings.nodaemon && !is_daemon )
|
||||
{
|
||||
logstring( "Normal", "--- Startup, daemonizing ---" );
|
||||
|
||||
daemonize( L );
|
||||
daemonize( L, settings.pidfile );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2053,7 +2050,10 @@ load_runner_func(
|
||||
| might actually close the monitors fd!
|
||||
*/
|
||||
static void
|
||||
daemonize( lua_State *L )
|
||||
daemonize(
|
||||
lua_State *L, // the lua state
|
||||
const char *pidfile // if not NULL write pidfile
|
||||
)
|
||||
{
|
||||
pid_t pid, sid;
|
||||
|
||||
@ -2070,14 +2070,21 @@ daemonize( lua_State *L )
|
||||
exit( -1 );
|
||||
}
|
||||
|
||||
if (pid > 0)
|
||||
if( pid > 0 )
|
||||
{
|
||||
// parent process returns to shell
|
||||
exit( 0 );
|
||||
}
|
||||
|
||||
if( pidfile )
|
||||
{
|
||||
write_pidfile( L, pidfile );
|
||||
}
|
||||
|
||||
|
||||
// detaches the new process from the parent process
|
||||
sid = setsid( );
|
||||
|
||||
if( sid < 0 )
|
||||
{
|
||||
printlogf(
|
||||
|
@ -4967,7 +4967,8 @@ runner.fsEventsEvent = Fsevents.event
|
||||
--
|
||||
-- Collector for every child process that finished in startup phase
|
||||
--
|
||||
function runner.collector(
|
||||
function runner.collector
|
||||
(
|
||||
pid, -- pid of the child process
|
||||
exitcode -- exitcode of the child process
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user