/* If we have outstanding children, then the application inherits
* them; we wish the application good luck with understanding
* this if and when it reaps them. */
- libxl__sigchld_removehandler(gc);
+ libxl__sigchld_notneeded(gc);
if (ctx->sigchld_selfpipe[0] >= 0) {
close(ctx->sigchld_selfpipe[0]);
sigchld_owner = 0;
}
-void libxl__sigchld_removehandler(libxl__gc *gc) /* non-reentrant */
+void libxl__sigchld_notneeded(libxl__gc *gc) /* non-reentrant, idempotent */
{
int rc;
}
}
-int libxl__sigchld_installhandler(libxl__gc *gc) /* non-reentrant */
+int libxl__sigchld_needed(libxl__gc *gc) /* non-reentrant, idempotent */
{
int r, rc;
abort();
}
-static void perhaps_removehandler(libxl__gc *gc)
+static void perhaps_sigchld_notneeded(libxl__gc *gc)
{
if (!chldmode_ours(CTX, 0))
- libxl__sigchld_removehandler(gc);
+ libxl__sigchld_notneeded(gc);
}
-static int perhaps_installhandler(libxl__gc *gc, bool creating)
+static int perhaps_sigchld_needed(libxl__gc *gc, bool creating)
{
int rc;
if (chldmode_ours(CTX, creating)) {
- rc = libxl__sigchld_installhandler(gc);
+ rc = libxl__sigchld_needed(gc);
if (rc) return rc;
}
return 0;
found:
childproc_reaped_ours(egc, ch, status);
- perhaps_removehandler(gc);
+ perhaps_sigchld_notneeded(gc);
return 0;
}
CTX_LOCK;
int rc;
- perhaps_installhandler(gc, 1);
+ perhaps_sigchld_needed(gc, 1);
pid_t pid =
CTX->childproc_hooks->fork_replacement
rc = pid;
out:
- perhaps_removehandler(gc);
+ perhaps_sigchld_notneeded(gc);
CTX_UNLOCK;
return rc;
}
ctx->childproc_hooks = hooks;
ctx->childproc_user = user;
- perhaps_removehandler(gc);
- perhaps_installhandler(gc, 0); /* idempotent, ok to ignore errors for now */
+ perhaps_sigchld_notneeded(gc);
+ perhaps_sigchld_needed(gc, 0); /* idempotent, ok to ignore errors for now */
CTX_UNLOCK;
GC_FREE;
/* Internal to fork and child reaping machinery */
extern const libxl_childproc_hooks libxl__childproc_default_hooks;
-int libxl__sigchld_installhandler(libxl__gc*); /* non-reentrant; logs errs */
-void libxl__sigchld_removehandler(libxl__gc*); /* non-reentrant */
+int libxl__sigchld_needed(libxl__gc*); /* non-reentrant idempotent, logs errs */
+void libxl__sigchld_notneeded(libxl__gc*); /* non-reentrant idempotent */
int libxl__self_pipe_wakeup(int fd); /* returns 0 or -1 setting errno */
int libxl__self_pipe_eatall(int fd); /* returns 0 or -1 setting errno */