[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 4/7] proc: implement proc_request_process_change_notification
From: |
Justus Winter |
Subject: |
[PATCH 4/7] proc: implement proc_request_process_change_notification |
Date: |
Mon, 16 Sep 2013 16:09:02 +0200 |
XXX
XXX
---
proc/Makefile | 5 +++--
proc/main.c | 3 +++
proc/mgt.c | 35 +++++++++++++++++++++++++++++++++++
proc/proc.h | 6 ++++++
4 files changed, 47 insertions(+), 2 deletions(-)
diff --git a/proc/Makefile b/proc/Makefile
index 2eed13c..97d9077 100644
--- a/proc/Makefile
+++ b/proc/Makefile
@@ -29,9 +29,10 @@ MIGSFLAGS="-DPROCESS_INTRAN=pstruct_t reqport_find
(process_t)" \
"-DPROCESS_IMPORTS=import \"proc.h\";"
MIGSTUBS = processServer.o notifyServer.o \
- ourmsgUser.o proc_excUser.o proc_excServer.o
+ ourmsgUser.o proc_excUser.o proc_excServer.o \
+ process_notifyUser.o
OBJS = $(SRCS:.c=.o) $(MIGSTUBS)
-HURDLIBS = ihash ports shouldbeinlibc
+HURDLIBS = ihash ports shouldbeinlibc hurdnotify
OTHERLIBS = -lpthread
include ../Makeconf
diff --git a/proc/main.c b/proc/main.c
index 73abbc0..f688a44 100644
--- a/proc/main.c
+++ b/proc/main.c
@@ -80,6 +80,9 @@ main (int argc, char **argv, char **envp)
ports_create_port (generic_port_class, proc_bucket,
sizeof (struct port_info), &genport);
generic_port = ports_get_right (genport);
+ hurd_notify_create (¬ify_on_process_change,
+ do_notify_process_changed,
+ NULL);
/* Create the initial proc object for init (PID 1). */
startup_proc = create_startup_proc ();
diff --git a/proc/mgt.c b/proc/mgt.c
index d7ad296..2d6c8e8 100644
--- a/proc/mgt.c
+++ b/proc/mgt.c
@@ -219,6 +219,10 @@ S_proc_child (struct proc *parentp,
childp->end_code = parentp->end_code;
}
+ /* XXX do the notification here in the mean time. */
+ /* Notify any process change listeners. */
+ hurd_notify_do_notify (notify_on_process_change, (void *) childp);
+
return 0;
}
@@ -697,6 +701,10 @@ new_proc (task_t task)
p = allocate_proc (task);
if (p)
complete_proc (p, genpid ());
+
+ /* XXX: once the kernel provides the parent task, do the
+ notification here */
+
return p;
}
@@ -774,6 +782,9 @@ process_has_exited (struct proc *p)
/* Cancel any outstanding RPCs done on behalf of the dying process. */
ports_interrupt_rpcs (p);
+
+ /* Notify any process change listeners. */
+ hurd_notify_do_notify (notify_on_process_change, (void *) p);
}
void
@@ -942,3 +953,27 @@ S_proc_get_code (struct proc *callerp,
return 0;
}
+
+/* XXX */
+error_t
+S_proc_request_process_change_notification (struct proc *callerp,
+ mach_port_t notify)
+{
+ if (!callerp)
+ return EOPNOTSUPP;
+
+ return hurd_notify_append (notify_on_process_change, notify, NULL);
+}
+
+error_t
+do_notify_process_changed (mach_port_t port,
+ mach_port_t reply_port,
+ void *data,
+ void *common_data)
+{
+ struct proc *p = common_data;
+ return notify_process_changed (port,
+ p->p_pid,
+ p->p_parent->p_pid,
+ p->p_dead);
+}
diff --git a/proc/proc.h b/proc/proc.h
index 80f8397..bf9b33b 100644
--- a/proc/proc.h
+++ b/proc/proc.h
@@ -26,6 +26,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA
02139, USA. */
#include <sys/mman.h>
#include <hurd/ports.h>
#include <hurd/ihash.h>
+#include <hurd/notify.h>
#include <pthread.h>
struct proc
@@ -140,6 +141,7 @@ struct port_bucket *proc_bucket;
struct port_class *proc_class;
struct port_class *generic_port_class;
struct port_class *exc_class;
+struct hurd_notify *notify_on_process_change;
mach_port_t master_host_port;
mach_port_t master_device_port;
@@ -213,5 +215,9 @@ void initialize_version_info (void);
void send_signal (mach_port_t, int, mach_port_t);
+error_t do_notify_process_changed (mach_port_t port,
+ mach_port_t reply_port,
+ void *data,
+ void *common_data);
#endif
--
1.7.10.4
- cgroupfs, /hurd/proc and subhurds, Justus Winter, 2013/09/16
- [PATCH 1/7] libnotify: add a general notification library, Justus Winter, 2013/09/16
- [PATCH 4/7] proc: implement proc_request_process_change_notification,
Justus Winter <=
- [PATCH 5/7] hurd: add proc_request_process_change_notification, Justus Winter, 2013/09/16
- [PATCH 6/7] FIX BUILD, Justus Winter, 2013/09/16
- [PATCH 2/7] init: use libhurdnotify for shutdown notifications, Justus Winter, 2013/09/16
- [PATCH 3/7] hurd: add notification callbacks for the process management, Justus Winter, 2013/09/16
- [PATCH 7/7] XXX: register for new task notifications, Justus Winter, 2013/09/16
- [PATCH] kern: new task notifications, Justus Winter, 2013/09/16
- Re: cgroupfs, /hurd/proc and subhurds, Ludovic Courtès, 2013/09/17