* proc/Makefile: XXX add gnumach stubs. * proc/main.c (message_demuxer): Add task_notify_server. (main): Register for new task notificatinos. (main): Get all tasks created prior to registering the notifications. * proc/mgt.c (S_mach_notify_new_task): Add server function. --- proc/Makefile | 5 +++++ proc/main.c | 15 ++++++++++++++- proc/mgt.c | 23 +++++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-)
diff --git a/proc/Makefile b/proc/Makefile index 97d9077..1b40e7d 100644 --- a/proc/Makefile +++ b/proc/Makefile @@ -32,6 +32,11 @@ MIGSTUBS = processServer.o notifyServer.o \ ourmsgUser.o proc_excUser.o proc_excServer.o \ process_notifyUser.o OBJS = $(SRCS:.c=.o) $(MIGSTUBS) + +# XXX: hacked up gnumach, you need to copy gnumach.defs and +# task_notify.defs here first +MIGSTUBS += gnumachUser.o task_notifyServer.o + HURDLIBS = ihash ports shouldbeinlibc hurdnotify OTHERLIBS = -lpthread diff --git a/proc/main.c b/proc/main.c index f688a44..c300cca 100644 --- a/proc/main.c +++ b/proc/main.c @@ -31,6 +31,8 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <pids.h> #include "proc.h" +#include "gnumach_U.h" +#include "task_notify_S.h" const char *argp_program_version = STANDARD_HURD_VERSION (proc); @@ -41,13 +43,15 @@ message_demuxer (mach_msg_header_t *inp, extern int process_server (mach_msg_header_t *, mach_msg_header_t *); extern int notify_server (mach_msg_header_t *, mach_msg_header_t *); extern int proc_exc_server (mach_msg_header_t *, mach_msg_header_t *); + extern int task_notify_server (mach_msg_header_t *, mach_msg_header_t *); int status; pthread_mutex_lock (&global_lock); status = (process_server (inp, outp) || notify_server (inp, outp) || ports_interrupt_server (inp, outp) - || proc_exc_server (inp, outp)); + || proc_exc_server (inp, outp) + || task_notify_server (inp, outp)); pthread_mutex_unlock (&global_lock); return status; } @@ -124,6 +128,15 @@ main (int argc, char **argv, char **envp) mach_port_deallocate (mach_task_self (), pset); mach_port_deallocate (mach_task_self (), psetcntl); + err = register_new_task_notification (master_host_port, + generic_port, + MACH_MSG_TYPE_MAKE_SEND); + assert_perror (err); + + /* Get all tasks that have been created prior to requesting the task + notifications. */ + add_tasks (NULL); + { /* Get our stderr set up to print on the console, in case we have to panic or something. */ diff --git a/proc/mgt.c b/proc/mgt.c index 2d6c8e8..3dc2fb6 100644 --- a/proc/mgt.c +++ b/proc/mgt.c @@ -977,3 +977,26 @@ do_notify_process_changed (mach_port_t port, p->p_parent->p_pid, p->p_dead); } + +error_t +S_mach_notify_new_task (mach_port_t notify, + mach_port_t task, + mach_port_t parent) +{ + struct proc *parentp = task_find_nocreate (parent); + mach_port_deallocate (mach_task_self (), parent); + if (! parentp) + { + /* XXX proper error handling */ + error (0, 0, "parent process not found"); + return ESRCH; + } + + struct proc *childp = task_find_nocreate (task); + if (! childp) + childp = new_proc (task); + + /* XXX do something interesting */ + + return 0; +} -- 1.7.10.4