MCPcopy Create free account
hub / github.com/ClusterLabs/pacemaker / start_child

Function start_child

mcp/pacemaker.c:223–331  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

221static char *opts_vgrind[] = { NULL, NULL, NULL, NULL, NULL };
222
223static gboolean
224start_child(pcmk_child_t * child)
225{
226 int lpc = 0;
227 uid_t uid = 0;
228 struct rlimit oflimits;
229 gboolean use_valgrind = FALSE;
230 gboolean use_callgrind = FALSE;
231 const char *devnull = "/dev/null";
232 const char *env_valgrind = getenv("PCMK_valgrind_enabled");
233 const char *env_callgrind = getenv("PCMK_callgrind_enabled");
234
235 child->active_before_startup = FALSE;
236
237 if (child->command == NULL) {
238 crm_info("Nothing to do for child \"%s\"", child->name);
239 return TRUE;
240 }
241
242 if (env_callgrind != NULL && crm_is_true(env_callgrind)) {
243 use_callgrind = TRUE;
244 use_valgrind = TRUE;
245
246 } else if (env_callgrind != NULL && strstr(env_callgrind, child->name)) {
247 use_callgrind = TRUE;
248 use_valgrind = TRUE;
249
250 } else if (env_valgrind != NULL && crm_is_true(env_valgrind)) {
251 use_valgrind = TRUE;
252
253 } else if (env_valgrind != NULL && strstr(env_valgrind, child->name)) {
254 use_valgrind = TRUE;
255 }
256
257 if (use_valgrind && strlen(VALGRIND_BIN) == 0) {
258 crm_warn("Cannot enable valgrind for %s:"
259 " The location of the valgrind binary is unknown", child->name);
260 use_valgrind = FALSE;
261 }
262
263 child->pid = fork();
264 CRM_ASSERT(child->pid != -1);
265
266 if (child->pid > 0) {
267 /* parent */
268 g_child_watch_add(child->pid, pcmk_child_exit, child);
269
270 crm_info("Forked child %d for process %s%s", child->pid, child->name,
271 use_valgrind ? " (valgrind enabled: " VALGRIND_BIN ")" : "");
272 update_node_processes(local_nodeid, NULL, get_process_list());
273 return TRUE;
274
275 } else {
276 /* Start a new session */
277 (void)setsid();
278
279 /* Setup the two alternate arg arrarys */
280 opts_vgrind[0] = strdup(VALGRIND_BIN);

Callers 2

pcmk_process_exitFunction · 0.85
init_children_processesFunction · 0.85

Calls 5

crm_is_trueFunction · 0.85
update_node_processesFunction · 0.85
crm_user_lookupFunction · 0.85
crm_exitFunction · 0.85
get_process_listFunction · 0.70

Tested by

no test coverage detected