Пример #1
0
static pid_t child_make(int i, int listenfd) {
  pid_t pid;
  if ((pid = fork_wrapper()) > 0)
    return pid;
  while(true) {
    wait_client(listenfd);
    start_transaction();
  }
  exit(0);
}
Пример #2
0
/// Interposes over the vfork() function.
/// It's nearly impossible to wrap vfork() since the docs say:
/// "The procedure that called vfork() should not
/// return while running in the child's context ...". Any
/// wrapper function would have to return to reach the exec().
/// So we convert vfork to fork. There may be a few corner
/// cases where this affects behavior but generally use of
/// vfork is an anachronism, and SUS does contain verbiage to
/// the effect that vfork may be equivalent to fork.
/// Better ideas solicited. In particular it appears that
/// we could hack in some assembler code to play with the
/// stack. See a response by Jonathan Adams in comp.unix.solaris
/// from 2004-09-17, subject 'how to "wrap" vfork?'
/// @return same as the wrapped function
/*static*/ pid_t
vfork(void)
{
    const char *call = "vfork";
    interposer_late_init(call);
    WRAPPER_DEBUG("ENTERING vfork_wrapper() => %p\n", fork_real);

    if (interposer_get_active()) {
	return fork_wrapper(call, fork_real);
    } else {
	return fork_real();
    }
}
Пример #3
0
/// @param[in] call     the name of the interposed function in string form
/// @param[in] next     a pointer to the interposed function
/// @return same as the wrapped function
/*static*/ pid_t
fork1_wrapper(const char *call, pid_t(*next) (void))
{
    return fork_wrapper(call, next);
}