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