summaryrefslogtreecommitdiffstats
path: root/sys/compat
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2014-12-15 12:01:42 +0000
committerkib <kib@FreeBSD.org>2014-12-15 12:01:42 +0000
commitc014fd46ecbcbeeee9989bc8fb1fdab425c10888 (patch)
treeb2f31aec2d05802cb12e66560e0af74d73c7e473 /sys/compat
parent3c08ea0611f83860ef6a4604ebd6e42116dda80c (diff)
downloadFreeBSD-src-c014fd46ecbcbeeee9989bc8fb1fdab425c10888.zip
FreeBSD-src-c014fd46ecbcbeeee9989bc8fb1fdab425c10888.tar.gz
Add a facility for non-init process to declare itself the reaper of
the orphaned descendants. Base of the API is modelled after the same feature from the DragonFlyBSD. Requested by: bapt Reviewed by: jilles (previous version) Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 3 weeks
Diffstat (limited to 'sys/compat')
-rw-r--r--sys/compat/freebsd32/freebsd32.h6
-rw-r--r--sys/compat/freebsd32/freebsd32_misc.c51
2 files changed, 53 insertions, 4 deletions
diff --git a/sys/compat/freebsd32/freebsd32.h b/sys/compat/freebsd32/freebsd32.h
index af10055..ed3df7a 100644
--- a/sys/compat/freebsd32/freebsd32.h
+++ b/sys/compat/freebsd32/freebsd32.h
@@ -390,4 +390,10 @@ struct kld32_file_stat {
char pathname[MAXPATHLEN];
};
+struct procctl_reaper_pids32 {
+ u_int rp_count;
+ u_int rp_pad0[15];
+ uint32_t rp_pids;
+};
+
#endif /* !_COMPAT_FREEBSD32_FREEBSD32_H_ */
diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c
index 24c5738..1457f57 100644
--- a/sys/compat/freebsd32/freebsd32_misc.c
+++ b/sys/compat/freebsd32/freebsd32_misc.c
@@ -2957,20 +2957,63 @@ int
freebsd32_procctl(struct thread *td, struct freebsd32_procctl_args *uap)
{
void *data;
- int error, flags;
+ union {
+ struct procctl_reaper_status rs;
+ struct procctl_reaper_pids rp;
+ struct procctl_reaper_kill rk;
+ } x;
+ union {
+ struct procctl_reaper_pids32 rp;
+ } x32;
+ int error, error1, flags;
switch (uap->com) {
case PROC_SPROTECT:
error = copyin(PTRIN(uap->data), &flags, sizeof(flags));
- if (error)
+ if (error != 0)
return (error);
data = &flags;
break;
+ case PROC_REAP_ACQUIRE:
+ case PROC_REAP_RELEASE:
+ if (uap->data != NULL)
+ return (EINVAL);
+ data = NULL;
+ break;
+ case PROC_REAP_STATUS:
+ data = &x.rs;
+ break;
+ case PROC_REAP_GETPIDS:
+ error = copyin(uap->data, &x32.rp, sizeof(x32.rp));
+ if (error != 0)
+ return (error);
+ CP(x32.rp, x.rp, rp_count);
+ PTRIN_CP(x32.rp, x.rp, rp_pids);
+ data = &x.rp;
+ break;
+ case PROC_REAP_KILL:
+ error = copyin(uap->data, &x.rk, sizeof(x.rk));
+ if (error != 0)
+ return (error);
+ data = &x.rk;
+ break;
default:
return (EINVAL);
}
- return (kern_procctl(td, uap->idtype, PAIR32TO64(id_t, uap->id),
- uap->com, data));
+ error = kern_procctl(td, uap->idtype, PAIR32TO64(id_t, uap->id),
+ uap->com, data);
+ switch (uap->com) {
+ case PROC_REAP_STATUS:
+ if (error == 0)
+ error = copyout(&x.rs, uap->data, sizeof(x.rs));
+ break;
+ case PROC_REAP_KILL:
+ error1 = copyout(&x.rk, uap->data, sizeof(x.rk));
+ if (error == 0)
+ error = error1;
+ break;
+ }
+ return (error);
}
int
OpenPOWER on IntegriCloud