return is_child;
}
+void ctdb_track_child(struct ctdb_context *ctdb, pid_t pid)
+{
+ char *process;
+
+ /* Only CTDB main daemon should track child processes */
+ if (getpid() != ctdb->ctdbd_pid) {
+ return;
+ }
+
+ process = talloc_asprintf(ctdb->child_processes, "process:%d", (int)pid);
+ trbt_insert32(ctdb->child_processes, pid, process);
+}
+
/*
* This function forks a child process and drops the realtime
* scheduler for the child process.
pid_t ctdb_fork_no_free_ringbuffer(struct ctdb_context *ctdb)
{
pid_t pid;
- char *process;
pid = fork();
if (pid == -1) {
return 0;
}
- if (getpid() != ctdb->ctdbd_pid) {
- return pid;
- }
-
- process = talloc_asprintf(ctdb->child_processes, "process:%d", (int)pid);
- trbt_insert32(ctdb->child_processes, pid, process);
-
+ ctdb_track_child(ctdb, pid);
return pid;
}
void ctdb_restore_scheduler(struct ctdb_context *ctdb);
struct tevent_signal *ctdb_init_sigchld(struct ctdb_context *ctdb);
+void ctdb_track_child(struct ctdb_context *ctdb, pid_t pid);
pid_t ctdb_fork(struct ctdb_context *ctdb);
pid_t ctdb_fork_no_free_ringbuffer(struct ctdb_context *ctdb);
void ctdb_set_child_info(TALLOC_CTX *mem_ctx, const char *child_name_fmt, ...);