Ejemplo n.º 1
0
pid_t
__wait(int *istat)
{
#ifdef VARIANT_CANCELABLE
	return (__wait4(WAIT_ANY, istat, 0, (struct rusage *)0));
#else /* !VARIANT_CANCELABLE */
	return (__wait4_nocancel(WAIT_ANY, istat, 0, (struct rusage *)0));
#endif /* VARIANT_CANCELABLE */
}
Ejemplo n.º 2
0
int __libc_system(const char *command)
{
	int wait_val, pid;
	struct sigaction sa, save_quit, save_int;
	sigset_t save_mask;

	if (command == 0)
		return 1;

	memset(&sa, 0, sizeof(sa));
	sa.sa_handler = SIG_IGN;
	/* __sigemptyset(&sa.sa_mask); - done by memset() */
	/* sa.sa_flags = 0; - done by memset() */

	sigaction(SIGQUIT, &sa, &save_quit);
	sigaction(SIGINT, &sa, &save_int);
	__sigaddset(&sa.sa_mask, SIGCHLD);
	sigprocmask(SIG_BLOCK, &sa.sa_mask, &save_mask);

	if ((pid = vfork()) < 0) {
		wait_val = -1;
		goto out;
	}
	if (pid == 0) {
		sigaction(SIGQUIT, &save_quit, NULL);
		sigaction(SIGINT, &save_int, NULL);
		sigprocmask(SIG_SETMASK, &save_mask, NULL);

		execl("/bin/sh", "sh", "-c", command, (char *) 0);
		_exit(127);
	}

#if 0
	__printf("Waiting for child %d\n", pid);
#endif

	if (__wait4_nocancel(pid, &wait_val, 0, 0) == -1)
		wait_val = -1;

out:
	sigaction(SIGQUIT, &save_quit, NULL);
	sigaction(SIGINT, &save_int, NULL);
	sigprocmask(SIG_SETMASK, &save_mask, NULL);
	return wait_val;
}