diff options
author | dchagin <dchagin@FreeBSD.org> | 2016-01-09 15:28:05 +0000 |
---|---|---|
committer | dchagin <dchagin@FreeBSD.org> | 2016-01-09 15:28:05 +0000 |
commit | 3c97a0093809814b043c4b6e6f23a66a38d564d3 (patch) | |
tree | 6b039ec578684547a3f640fe6950ed0e6c8c4c1d /sys/compat | |
parent | fb0e6af659052c791bfb57d67fd1795f816bf094 (diff) | |
download | FreeBSD-src-3c97a0093809814b043c4b6e6f23a66a38d564d3.zip FreeBSD-src-3c97a0093809814b043c4b6e6f23a66a38d564d3.tar.gz |
MFC r283394:
Implement waitid() system call.
Diffstat (limited to 'sys/compat')
-rw-r--r-- | sys/compat/linux/linux_misc.c | 62 | ||||
-rw-r--r-- | sys/compat/linux/linux_misc.h | 6 |
2 files changed, 68 insertions, 0 deletions
diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c index d9e1834..f54018d 100644 --- a/sys/compat/linux/linux_misc.c +++ b/sys/compat/linux/linux_misc.c @@ -916,6 +916,68 @@ linux_wait4(struct thread *td, struct linux_wait4_args *args) } int +linux_waitid(struct thread *td, struct linux_waitid_args *args) +{ + int status, options, sig; + struct __wrusage wru; + siginfo_t siginfo; + l_siginfo_t lsi; + idtype_t idtype; + struct proc *p; + int error; + + options = 0; + linux_to_bsd_waitopts(args->options, &options); + + if (options & ~(WNOHANG | WNOWAIT | WEXITED | WUNTRACED | WCONTINUED)) + return (EINVAL); + if (!(options & (WEXITED | WUNTRACED | WCONTINUED))) + return (EINVAL); + + switch (args->idtype) { + case LINUX_P_ALL: + idtype = P_ALL; + break; + case LINUX_P_PID: + if (args->id <= 0) + return (EINVAL); + idtype = P_PID; + break; + case LINUX_P_PGID: + if (args->id <= 0) + return (EINVAL); + idtype = P_PGID; + break; + default: + return (EINVAL); + } + + error = kern_wait6(td, idtype, args->id, &status, options, + &wru, &siginfo); + if (error != 0) + return (error); + if (args->rusage != NULL) { + error = linux_copyout_rusage(&wru.wru_children, + args->rusage); + if (error != 0) + return (error); + } + if (args->info != NULL) { + p = td->td_proc; + if (td->td_retval[0] == 0) + bzero(&lsi, sizeof(lsi)); + else { + sig = BSD_TO_LINUX_SIGNAL(siginfo.si_signo); + siginfo_to_lsiginfo(&siginfo, &lsi, sig); + } + error = copyout(&lsi, args->info, sizeof(lsi)); + } + td->td_retval[0] = 0; + + return (error); +} + +int linux_mknod(struct thread *td, struct linux_mknod_args *args) { char *path; diff --git a/sys/compat/linux/linux_misc.h b/sys/compat/linux/linux_misc.h index a25ba73..ccbcd4d 100644 --- a/sys/compat/linux/linux_misc.h +++ b/sys/compat/linux/linux_misc.h @@ -123,6 +123,12 @@ extern int stclohz; #define __WALL 0x40000000 #define __WCLONE 0x80000000 +/* Linux waitid idtype */ +#define LINUX_P_ALL 0 +#define LINUX_P_PID 1 +#define LINUX_P_PGID 2 + + int linux_common_wait(struct thread *td, int pid, int *status, int options, struct rusage *ru); void linux_to_bsd_waitopts(int options, int *bsdopts); |