The Assimilation Project
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ChildProcess class.

Class for creating and monitoring child processes in the gmainloop environment. More...

Collaboration diagram for ChildProcess class.:

Macros

#define CHILDSTATE_RUNNING   0
 

Functions

FSTATIC void _childprocess_setup_child (gpointer childprocess_object)
 Function to perform setup for child between fork and exec (for UNIX-like systems) It doesn't get called under Windows. More...
 
FSTATIC gboolean _childprocess_timeout (gpointer childprocess_object)
 Function to handle child timeouts. More...
 
FSTATIC void _childprocess_childexit (GPid pid, gint status, gpointer childprocess_object)
 Function called when the child (finally) exits... More...
 
FSTATIC void _childprocess_finalize (AssimObj *aself)
 Routine to free/destroy/finalize our ChildProcess objects. More...
 
FSTATIC gchar * _childprocess_toString (gconstpointer)
 
WINEXPORT ChildProcesschildprocess_new (gsize cpsize, char **argv, const char **envp, ConfigContext *envmod, const char *curdir, void(*notify)(ChildProcess *, enum HowDied, int rc, int signal, gboolean core_dumped), gboolean save_stdout, const char *logdomain, const char *logprefix, GLogLevelFlags loglevel, guint32 timeout_seconds, gpointer user_data, enum ChildErrLogMode logmode, const char *logname)
 ChildProcess class. constructor. More...
 
typedef struct _ChildProcess ChildProcess
 

Detailed Description

Class for creating and monitoring child processes in the gmainloop environment.

It logs stderr, and can either save or log stdout - creator's choice.

Macro Definition Documentation

#define CHILDSTATE_RUNNING   0

Definition at line 51 of file childprocess.c.

Referenced by _childprocess_childexit(), and childprocess_new().

Typedef Documentation

typedef struct _ChildProcess ChildProcess

Definition at line 33 of file childprocess.h.

Function Documentation

FSTATIC void _childprocess_childexit ( GPid  pid,
gint  status,
gpointer  childprocess_object 
)

Function called when the child (finally) exits...

Definition at line 276 of file childprocess.c.

References __FUNCTION__, CASTTOCLASS, CHILD_LOGALL, CHILD_LOGERRS, CHILD_NOLOG, CHILDSTATE_RUNNING, DEBUGMSG2, DEBUGMSG3, DEBUGMSG5, DIMOF, EXITED_HUNG, EXITED_NONZERO, EXITED_SIGNAL, EXITED_TIMEOUT, EXITED_ZERO, cma.cma::exitrc, NOT_EXITED, signal, and UNREF.

Referenced by _childprocess_timeout(), and childprocess_new().

Here is the caller graph for this function:

FSTATIC void _childprocess_finalize ( AssimObj self)

Routine to free/destroy/finalize our ChildProcess objects.

Definition at line 188 of file childprocess.c.

References __FUNCTION__, _assimobj_finalize(), CASTTOCLASS, and DEBUGMSG3.

Referenced by childprocess_new().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC void _childprocess_setup_child ( gpointer  childprocess_object)

Function to perform setup for child between fork and exec (for UNIX-like systems) It doesn't get called under Windows.

Definition at line 221 of file childprocess.c.

References CASTTOCLASS.

Referenced by childprocess_new().

Here is the caller graph for this function:

FSTATIC gboolean _childprocess_timeout ( gpointer  childprocess_object)

Function to handle child timeouts.

It implements a very simple, linear state machine...

Definition at line 252 of file childprocess.c.

References __FUNCTION__, _childprocess_childexit(), CASTTOCLASS, DEBUGMSG, and DIMOF.

Referenced by childprocess_new().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC char * _childprocess_toString ( gconstpointer  aself)

Definition at line 375 of file childprocess.c.

References _ConfigContext::baseclass, CASTTOCONSTCLASS, configcontext_new(), _ConfigContext::setint, _ConfigContext::setstring, _AssimObj::toString, and UNREF.

Referenced by childprocess_new().

Here is the call graph for this function:

Here is the caller graph for this function:

WINEXPORT ChildProcess* childprocess_new ( gsize  cpsize,
char **  argv,
const char **  envp,
ConfigContext envmod,
const char *  curdir,
void(*)(ChildProcess *, enum HowDied, int rc, int signal, gboolean core_dumped)  notify,
gboolean  save_stdout,
const char *  logdomain,
const char *  logprefix,
GLogLevelFlags  loglevel,
guint32  timeout_seconds,
gpointer  user_data,
enum ChildErrLogMode  logmode,
const char *  logname 
)

ChildProcess class. constructor.

Here's what we're going to do: 1) Create child process using g_spawn_async_with_pipes() 2) ...In child process become our own process group 3) Create LogSourceFd object for stderr 4) Create LogSourceFd or GMainFd object for stdout 5) Set timer (if any) 6) Initialize the child state to running 7) Return.

Parameters
cpsizeSize of created ChildProcess object
argvNULL-terminated argv for the ChildProcess
envpEnvironment for the ChildProcess
envmodModifications to the ChildProcess environment
curdirCurrent directory to start the child in
notifyFunction to call if/when the child terminates
save_stdoutTRUE to save stdout, FALSE to log it
logdomainGlib log domain
logprefixPrefix to prepend to log entries
loglevelGlib Log level
timeout_secondsHow long to wait before killing it - zero for no timeout
user_dataData our user wants us to keep
logmodeHow to log child exits
lognameName to use when logging child exits as requested

Definition at line 85 of file childprocess.c.

References __FUNCTION__, _childprocess_childexit(), _childprocess_finalize(), _childprocess_setup_child(), _childprocess_timeout(), _childprocess_toString(), _AssimObj::_finalize, assim_free_environ(), assim_merge_environ(), assimobj_new(), _LogSourceFd::baseclass, BINDDEBUG, CHILDSTATE_RUNNING, DEBUGMSG2, DEBUGMSG3, DEBUGMSG5, gmainfd_new(), logsourcefd_new(), NEWSUBCLASS, REF, _AssimObj::toString, and UNREF.

Referenced by _jsondiscovery_discover(), _resourcelsb_execute(), _resourceocf_execute(), generic_childprocess_test(), and test_childprocess_failure().

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

int { ... } next_timeout

Definition at line 239 of file childprocess.c.

int { ... } signal

Definition at line 238 of file childprocess.c.