Ejemplo n.º 1
0
    static int waitpid_while_debugging_stub(int pid, int* status, int options)
    {
        static int number_called = 0;
        static int saved_status;

        if (number_called++ < 10) {
            saved_status = *status;
            errno=EINTR;
            return -1;
        }
        else {
            *status = saved_status;
            return original_waitpid(pid, status, options);
        }
    }
Ejemplo n.º 2
0
pid_t waitpid(pid_t pid, int *status, int options)
{
	int status_; //status might be NULL, thus we use status_ to retrive the state.
	pid_t pidb;
	typeof(waitpid) *original_waitpid = dlsym(RTLD_NEXT, "waitpid");

	debug(D_DEBUG, "waiting from %d.\n", getpid());
	pidb = original_waitpid(pid, &status_, options);

	if(WIFEXITED(status_) || WIFSIGNALED(status_))
	{
		struct monitor_msg msg;
		msg.type   = END;
		msg.origin = getpid();
		msg.data.p = pidb;

		send_monitor_msg(&msg);
	}

	if(status)
		*status = status_;

	return pid;
}