compat_wait4.c revision 1.2
11.2Schristos/* $NetBSD: compat_wait4.c,v 1.2 2009/01/11 02:46:27 christos Exp $ */ 21.2Schristos 31.2Schristos/*- 41.2Schristos * Copyright (c) 2008 The NetBSD Foundation, Inc. 51.2Schristos * All rights reserved. 61.2Schristos * 71.2Schristos * This code is derived from software contributed to The NetBSD Foundation 81.2Schristos * by Christos Zoulas. 91.2Schristos * 101.2Schristos * Redistribution and use in source and binary forms, with or without 111.2Schristos * modification, are permitted provided that the following conditions 121.2Schristos * are met: 131.2Schristos * 1. Redistributions of source code must retain the above copyright 141.2Schristos * notice, this list of conditions and the following disclaimer. 151.2Schristos * 2. Redistributions in binary form must reproduce the above copyright 161.2Schristos * notice, this list of conditions and the following disclaimer in the 171.2Schristos * documentation and/or other materials provided with the distribution. 181.2Schristos * 191.2Schristos * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 201.2Schristos * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 211.2Schristos * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 221.2Schristos * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 231.2Schristos * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 241.2Schristos * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 251.2Schristos * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 261.2Schristos * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 271.2Schristos * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 281.2Schristos * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 291.2Schristos * POSSIBILITY OF SUCH DAMAGE. 301.2Schristos */ 311.2Schristos 321.2Schristos#include <sys/cdefs.h> 331.2Schristos#if defined(LIBC_SCCS) && !defined(lint) 341.2Schristos__RCSID("$NetBSD: compat_wait4.c,v 1.2 2009/01/11 02:46:27 christos Exp $"); 351.2Schristos#endif /* LIBC_SCCS and not lint */ 361.2Schristos 371.2Schristos#define __LIBC12_SOURCE__ 381.2Schristos 391.2Schristos#include "namespace.h" 401.2Schristos#include <sys/types.h> 411.2Schristos#include <sys/wait.h> 421.2Schristos#include <compat/sys/wait.h> 431.2Schristos#include <sys/resource.h> 441.2Schristos#include <compat/sys/resource.h> 451.2Schristos 461.2Schristos__warn_references(wait3, 471.2Schristos "warning: reference to compatibility wait3(); include <sys/wait.h> to generate correct reference") 481.2Schristos__warn_references(wait4, 491.2Schristos "warning: reference to compatibility wait4(); include <sys/wait.h> to generate correct reference") 501.2Schristos 511.2Schristosextern void __rusage_to_rusage50(const struct rusage *, struct rusage50 *); 521.2Schristos 531.2Schristos#ifdef __weak_alias 541.2Schristos__weak_alias(wait4, _wait4) 551.2Schristos__weak_alias(_sys_wait4, _wait4) 561.2Schristos__weak_alias(wait3, _wait3) 571.2Schristos#endif 581.2Schristos 591.2Schristos/* 601.2Schristos * libc12 compatible wait4 routine. 611.2Schristos */ 621.2Schristosint 631.2Schristoswait3(int *status, int options, struct rusage50 *ru50) 641.2Schristos{ 651.2Schristos struct rusage ru; 661.2Schristos int rv; 671.2Schristos 681.2Schristos if ((rv = __wait350(status, options, ru50 ? &ru : NULL)) == -1) 691.2Schristos return rv; 701.2Schristos if (ru50) 711.2Schristos __rusage_to_rusage50(&ru, ru50); 721.2Schristos return rv; 731.2Schristos} 741.2Schristos 751.2Schristosint 761.2Schristoswait4(pid_t wpid, int *status, int options, struct rusage50 *ru50) 771.2Schristos{ 781.2Schristos struct rusage ru; 791.2Schristos int rv; 801.2Schristos 811.2Schristos if ((rv = __wait450(wpid, status, options, ru50 ? &ru : NULL)) == -1) 821.2Schristos return rv; 831.2Schristos if (ru50) 841.2Schristos __rusage_to_rusage50(&ru, ru50); 851.2Schristos return rv; 861.2Schristos} 87