1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
From 672950d7b5402ed7d2a35a458b83598a60c7f73a Mon Sep 17 00:00:00 2001
From: Justus Winter <4winter@informatik.uni-hamburg.de>
Date: Mon, 16 Sep 2013 16:09:05 +0200
Subject: [PATCH hurd 11/14] proc: register for new task notifications
* proc/Makefile (MIGSTUBS): Add `gnumachServer.o'.
* proc/main.c (message_demuxer): Handle the `task_notify' protocol.
(main): Register for new task notificatinos.
* proc/mgt.c (S_mach_notify_new_task): Add server function.
---
proc/Makefile | 4 +++-
proc/main.c | 11 ++++++++++-
proc/mgt.c | 35 ++++++++++++++++++++++++++++++++++-
3 files changed, 47 insertions(+), 3 deletions(-)
diff --git a/proc/Makefile b/proc/Makefile
index aa31ffb..2275a66 100644
--- a/proc/Makefile
+++ b/proc/Makefile
@@ -27,9 +27,11 @@ SRCS = wait.c hash.c host.c info.c main.c mgt.c notify.c pgrp.c msg.c \
MIGSFLAGS = -imacros $(srcdir)/mig-mutate.h
MIGSTUBS = processServer.o notifyServer.o \
- ourmsgUser.o proc_excUser.o proc_excServer.o
+ ourmsgUser.o proc_excUser.o proc_excServer.o \
+ task_notifyServer.o
OBJS = $(SRCS:.c=.o) $(MIGSTUBS)
HURDLIBS = ihash ports shouldbeinlibc
+
OTHERLIBS = -lpthread
include ../Makeconf
diff --git a/proc/main.c b/proc/main.c
index 3419d44..b4288fb 100644
--- a/proc/main.c
+++ b/proc/main.c
@@ -31,6 +31,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <pids.h>
#include "proc.h"
+#include "gnumach_U.h"
const char *argp_program_version = STANDARD_HURD_VERSION (proc);
@@ -38,6 +39,7 @@ const char *argp_program_version = STANDARD_HURD_VERSION (proc);
#include "notify_S.h"
#include "../libports/interrupt_S.h"
#include "proc_exc_S.h"
+#include "task_notify_S.h"
int
message_demuxer (mach_msg_header_t *inp,
@@ -47,7 +49,8 @@ message_demuxer (mach_msg_header_t *inp,
if ((routine = process_server_routine (inp)) ||
(routine = notify_server_routine (inp)) ||
(routine = ports_interrupt_server_routine (inp)) ||
- (routine = proc_exc_server_routine (inp)))
+ (routine = proc_exc_server_routine (inp)) ||
+ (routine = task_notify_server_routine (inp)))
{
pthread_mutex_lock (&global_lock);
(*routine) (inp, outp);
@@ -152,6 +155,12 @@ main (int argc, char **argv, char **envp)
if (err)
error (0, err, "Increasing priority failed");
+ err = register_new_task_notification (_hurd_host_priv,
+ generic_port,
+ MACH_MSG_TYPE_MAKE_SEND);
+ if (err)
+ error (0, err, "Registering task notifications failed");
+
{
/* 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 02d69db..32408ae 100644
--- a/proc/mgt.c
+++ b/proc/mgt.c
@@ -1,5 +1,5 @@
/* Process management
- Copyright (C) 1992,93,94,95,96,99,2000,01,02,13
+ Copyright (C) 1992,93,94,95,96,99,2000,01,02,13,14
Free Software Foundation, Inc.
This file is part of the GNU Hurd.
@@ -981,3 +981,36 @@ S_proc_get_code (struct proc *callerp,
return 0;
}
+
+/* Handle new task notifications from the kernel. */
+error_t
+S_mach_notify_new_task (mach_port_t notify,
+ mach_port_t task,
+ mach_port_t parent)
+{
+ struct proc *parentp, *childp;
+
+ if (notify != generic_port)
+ return EOPNOTSUPP;
+
+ parentp = task_find_nocreate (parent);
+ if (! parentp)
+ {
+ mach_port_deallocate (mach_task_self (), task);
+ mach_port_deallocate (mach_task_self (), parent);
+ return ESRCH;
+ }
+
+ childp = task_find_nocreate (task);
+ if (! childp)
+ {
+ mach_port_mod_refs (mach_task_self (), task, MACH_PORT_RIGHT_SEND, +1);
+ childp = new_proc (task);
+ }
+
+ /* XXX do something interesting */
+
+ mach_port_deallocate (mach_task_self (), task);
+ mach_port_deallocate (mach_task_self (), parent);
+ return 0;
+}
--
2.1.1
|