static pid_t (*plibc_func)(void) = NULL;
sigset_t sigset;
pid_t retval;
+ int saved_errno;
if (plibc_func == NULL) {
plibc_func = dlsym(RTLD_NEXT, "fork");
ust_before_fork(&sigset);
/* Do the real fork */
retval = plibc_func();
+ saved_errno = errno;
if (retval == 0) {
/* child */
ust_after_fork_child(&sigset);
} else {
ust_after_fork_parent(&sigset);
}
+ errno = saved_errno;
return retval;
}
static int (*plibc_func)(int nochdir, int noclose) = NULL;
sigset_t sigset;
int retval;
+ int saved_errno;
if (plibc_func == NULL) {
plibc_func = dlsym(RTLD_NEXT, "daemon");
ust_before_fork(&sigset);
/* Do the real daemon call */
retval = plibc_func(nochdir, noclose);
+ saved_errno = errno;
if (retval == 0) {
/* child, parent called _exit() directly */
ust_after_fork_child(&sigset);
/* on error in the parent */
ust_after_fork_parent(&sigset);
}
+ errno = saved_errno;
return retval;
}
/* end of var args */
va_list ap;
int retval;
+ int saved_errno;
va_start(ap, arg);
ptid = va_arg(ap, pid_t *);
*/
retval = plibc_func(fn, child_stack, flags, arg, ptid,
tls, ctid);
+ saved_errno = errno;
} else {
/* Creating a real process, we need to intervene. */
struct ustfork_clone_info info = { .fn = fn, .arg = arg };
ust_before_fork(&info.sigset);
retval = plibc_func(clone_fn, child_stack, flags, &info,
ptid, tls, ctid);
+ saved_errno = errno;
/* The child doesn't get here. */
ust_after_fork_parent(&info.sigset);
}
+ errno = saved_errno;
return retval;
}
static pid_t (*plibc_func)(void) = NULL;
sigset_t sigset;
pid_t retval;
+ int saved_errno;
if (plibc_func == NULL) {
plibc_func = dlsym(RTLD_NEXT, "rfork");
ust_before_fork(&sigset);
/* Do the real rfork */
retval = plibc_func();
+ saved_errno = errno;
if (retval == 0) {
/* child */
ust_after_fork_child(&sigset);
} else {
ust_after_fork_parent(&sigset);
}
+ errno = saved_errno;
return retval;
}