$NetBSD: patch-ad,v 1.6 2007/02/18 11:40:10 wiz Exp $ --- pth_syscall.c.orig 2006-06-08 17:54:03.000000000 +0000 +++ pth_syscall.c @@ -57,6 +57,7 @@ #define sendto __pth_sys_sendto #define pread __pth_sys_pread #define pwrite __pth_sys_pwrite +#define wait4 __pth_sys_wait4 /* include the private header and this way system headers */ #include "pth_p.h" @@ -108,6 +109,7 @@ int pth_syscall_hard = PTH_SYSCALL_HARD; #undef sendto #undef pread #undef pwrite +#undef wait4 /* internal data structures */ #if cpp @@ -157,13 +159,18 @@ intern pth_syscall_fct_tab_t pth_syscall #define PTH_SCF_sendto 19 #define PTH_SCF_pread 20 #define PTH_SCF_pwrite 21 +#define PTH_SCF_wait4 22 { "fork", NULL }, { "waitpid", NULL }, { "system", NULL }, { "nanosleep", NULL }, { "usleep", NULL }, { "sleep", NULL }, +#if defined(__NetBSD__) + { "__sigprocmask14", NULL }, +#else { "sigprocmask", NULL }, +#endif { "sigwait", NULL }, { "select", NULL }, { "poll", NULL }, @@ -179,6 +186,7 @@ intern pth_syscall_fct_tab_t pth_syscall { "sendto", NULL }, { "pread", NULL }, { "pwrite", NULL }, + { "wait4", NULL }, { NULL, NULL } }; #endif @@ -405,6 +413,8 @@ intern pid_t pth_sc_waitpid(pid_t wpid, (wpid, status, options); #if defined(HAVE_SYSCALL) && defined(SYS_waitpid) else return (pid_t)syscall(SYS_waitpid, wpid, status, options); +#elif defined(HAVE_SYSCALL) && defined(SYS_wait4) + else return (pid_t)syscall(SYS_wait4, wpid, status, options, (struct rusage *) NULL); #else else PTH_SYSCALL_ERROR(-1, ENOSYS, "waitpid"); #endif @@ -721,5 +731,27 @@ intern ssize_t pth_sc_sendto(int fd, con #endif } +/* ==== Pth hard syscall wrapper for wait4(2) ==== */ +pid_t wait4(pid_t, int *, int, struct rusage *); +pid_t wait4(pid_t wpid, int *status, int options, struct rusage *rusage) +{ + /* external entry point for application */ + pth_implicit_init(); + return pth_wait4(wpid, status, options, rusage); +} +intern pid_t pth_sc_wait4(pid_t wpid, int *status, int options, struct rusage *rusage) +{ + /* internal exit point for Pth */ + if (pth_syscall_fct_tab[PTH_SCF_wait4].addr != NULL) + return ((pid_t (*)(pid_t, int *, int, struct rusage *)) + pth_syscall_fct_tab[PTH_SCF_wait4].addr) + (wpid, status, options, rusage); +#if defined(HAVE_SYSCALL) && defined(SYS_wait4) + else return (pid_t)syscall(SYS_wait4, wpid, status, options, rusage); +#else + else PTH_SYSCALL_ERROR(-1, ENOSYS, "wait4"); +#endif +} + #endif /* PTH_SYSCALL_HARD */