From 9d5c178b241e12c601ad4d986e658792932f343a Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Mon, 24 Sep 2012 16:20:09 +0300 Subject: [PATCH] server: Use waitpid() instead of wait4(). --- configure | 4 +--- configure.ac | 4 +--- include/config.h.in | 6 ------ server/ptrace.c | 22 +++++++++++----------- server/request.c | 2 +- tools/winapi/nativeapi.dat | 1 - 6 files changed, 14 insertions(+), 25 deletions(-) diff --git a/configure b/configure index 21044af2c42..911f387b657 100755 --- a/configure +++ b/configure @@ -12994,9 +12994,7 @@ for ac_func in \ thr_kill2 \ timegm \ usleep \ - vsnprintf \ - wait4 \ - waitpid \ + vsnprintf do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` diff --git a/configure.ac b/configure.ac index 84b5de8a932..79b1175a629 100644 --- a/configure.ac +++ b/configure.ac @@ -2046,9 +2046,7 @@ AC_CHECK_FUNCS(\ thr_kill2 \ timegm \ usleep \ - vsnprintf \ - wait4 \ - waitpid \ + vsnprintf ) CFLAGS="$ac_save_CFLAGS" diff --git a/include/config.h.in b/include/config.h.in index a00fc1c54cc..c1f29bc3941 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -1076,12 +1076,6 @@ /* Define to 1 if you have the `vsnprintf' function. */ #undef HAVE_VSNPRINTF -/* Define to 1 if you have the `wait4' function. */ -#undef HAVE_WAIT4 - -/* Define to 1 if you have the `waitpid' function. */ -#undef HAVE_WAITPID - /* Define to 1 if you have the header file. */ #undef HAVE_X11_EXTENSIONS_SHAPE_H diff --git a/server/ptrace.c b/server/ptrace.c index 912f90eb180..efcdec0aa33 100644 --- a/server/ptrace.c +++ b/server/ptrace.c @@ -98,7 +98,7 @@ static inline int ptrace(int req, ...) { errno = EPERM; return -1; /*FAIL*/ } #endif /* HAVE_SYS_PTRACE_H */ -/* handle a status returned by wait4 */ +/* handle a status returned by waitpid */ static int handle_child_status( struct thread *thread, int pid, int status, int want_sig ) { if (WIFSTOPPED(status)) @@ -130,20 +130,20 @@ static int handle_child_status( struct thread *thread, int pid, int status, int return 0; } -/* wait4 wrapper to handle missing __WALL flag in older kernels */ -static inline pid_t wait4_wrapper( pid_t pid, int *status, int options, struct rusage *usage ) +/* waitpid wrapper to handle missing __WALL flag in older kernels */ +static inline pid_t waitpid_wrapper( pid_t pid, int *status, int options ) { #ifdef __WALL static int wall_flag = __WALL; for (;;) { - pid_t ret = wait4( pid, status, options | wall_flag, usage ); + pid_t ret = waitpid( pid, status, options | wall_flag ); if (ret != -1 || !wall_flag || errno != EINVAL) return ret; wall_flag = 0; } #else - return wait4( pid, status, options, usage ); + return waitpid( pid, status, options ); #endif } @@ -154,7 +154,7 @@ void sigchld_callback(void) for (;;) { - if (!(pid = wait4_wrapper( -1, &status, WUNTRACED | WNOHANG, NULL ))) break; + if (!(pid = waitpid_wrapper( -1, &status, WUNTRACED | WNOHANG ))) break; if (pid != -1) { struct thread *thread = get_thread_from_tid( pid ); @@ -182,26 +182,26 @@ static int get_ptrace_tid( struct thread *thread ) } /* wait for a ptraced child to get a certain signal */ -static int wait4_thread( struct thread *thread, int signal ) +static int waitpid_thread( struct thread *thread, int signal ) { int res, status; start_watchdog(); for (;;) { - if ((res = wait4_wrapper( get_ptrace_pid(thread), &status, WUNTRACED, NULL )) == -1) + if ((res = waitpid_wrapper( get_ptrace_pid(thread), &status, WUNTRACED )) == -1) { if (errno == EINTR) { if (!watchdog_triggered()) continue; - if (debug_level) fprintf( stderr, "%04x: *watchdog* wait4 aborted\n", thread->id ); + if (debug_level) fprintf( stderr, "%04x: *watchdog* waitpid aborted\n", thread->id ); } else if (errno == ECHILD) /* must have died */ { thread->unix_pid = -1; thread->unix_tid = -1; } - else perror( "wait4" ); + else perror( "waitpid" ); stop_watchdog(); return 0; } @@ -292,7 +292,7 @@ static int suspend_for_ptrace( struct thread *thread ) if (errno == ESRCH) thread->unix_pid = thread->unix_tid = -1; /* thread got killed */ goto error; } - if (wait4_thread( thread, SIGSTOP )) return 1; + if (waitpid_thread( thread, SIGSTOP )) return 1; resume_after_ptrace( thread ); error: set_error( STATUS_ACCESS_DENIED ); diff --git a/server/request.c b/server/request.c index 05c74645131..8d6a7f94c27 100644 --- a/server/request.c +++ b/server/request.c @@ -801,7 +801,7 @@ void open_master_socket(void) if (read( sync_pipe[0], &dummy, 1 ) == 1) _exit(0); /* child terminated, propagate exit status */ - wait4( pid, &status, 0, NULL ); + waitpid( pid, &status, 0 ); if (WIFEXITED(status)) _exit( WEXITSTATUS(status) ); _exit(1); } diff --git a/tools/winapi/nativeapi.dat b/tools/winapi/nativeapi.dat index bc25152b9d1..ade20b5ee68 100644 --- a/tools/winapi/nativeapi.dat +++ b/tools/winapi/nativeapi.dat @@ -251,7 +251,6 @@ utime vfprintf vsnprintf vsprintf -wait4 write y0 y1