diff options
author | dchagin <dchagin@FreeBSD.org> | 2016-01-09 15:23:54 +0000 |
---|---|---|
committer | dchagin <dchagin@FreeBSD.org> | 2016-01-09 15:23:54 +0000 |
commit | a14064e328e84be7d749f513956026f7f22e60b2 (patch) | |
tree | 2c9c15a7288e06d20cf37c57f01f3f1aa0bc387b /sys/compat/linux | |
parent | 778af4f786b2616dc167e39728e9ccd274f98fa1 (diff) | |
download | FreeBSD-src-a14064e328e84be7d749f513956026f7f22e60b2.zip FreeBSD-src-a14064e328e84be7d749f513956026f7f22e60b2.tar.gz |
MFC r283391:
To reduce code duplication introduce linux_copyout_rusage() method.
Use it in linux_wait4() system call and move linux_wait4() to the MI path.
While here add a prototype for the static bsd_to_linux_rusage().
Diffstat (limited to 'sys/compat/linux')
-rw-r--r-- | sys/compat/linux/linux_misc.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c index 345dd22..d9e1834 100644 --- a/sys/compat/linux/linux_misc.c +++ b/sys/compat/linux/linux_misc.c @@ -885,6 +885,35 @@ linux_waitpid(struct thread *td, struct linux_waitpid_args *args) return (linux_common_wait(td, args->pid, args->status, options, NULL)); } +int +linux_wait4(struct thread *td, struct linux_wait4_args *args) +{ + int error, options; + struct rusage ru, *rup; + +#ifdef DEBUG + if (ldebug(wait4)) + printf(ARGS(wait4, "%d, %p, %d, %p"), + args->pid, (void *)args->status, args->options, + (void *)args->rusage); +#endif + + options = (args->options & (WNOHANG | WUNTRACED)); + /* WLINUXCLONE should be equal to __WCLONE, but we make sure */ + if (args->options & __WCLONE) + options |= WLINUXCLONE; + + if (args->rusage != NULL) + rup = &ru; + else + rup = NULL; + error = linux_common_wait(td, args->pid, args->status, options, rup); + if (error != 0) + return (error); + if (args->rusage != NULL) + error = linux_copyout_rusage(&ru, args->rusage); + return (error); +} int linux_mknod(struct thread *td, struct linux_mknod_args *args) |