server: Use waitpid() instead of wait4().
This commit is contained in:
parent
934293c1ec
commit
9d5c178b24
|
@ -12994,9 +12994,7 @@ for ac_func in \
|
||||||
thr_kill2 \
|
thr_kill2 \
|
||||||
timegm \
|
timegm \
|
||||||
usleep \
|
usleep \
|
||||||
vsnprintf \
|
vsnprintf
|
||||||
wait4 \
|
|
||||||
waitpid \
|
|
||||||
|
|
||||||
do :
|
do :
|
||||||
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
|
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
|
||||||
|
|
|
@ -2046,9 +2046,7 @@ AC_CHECK_FUNCS(\
|
||||||
thr_kill2 \
|
thr_kill2 \
|
||||||
timegm \
|
timegm \
|
||||||
usleep \
|
usleep \
|
||||||
vsnprintf \
|
vsnprintf
|
||||||
wait4 \
|
|
||||||
waitpid \
|
|
||||||
)
|
)
|
||||||
CFLAGS="$ac_save_CFLAGS"
|
CFLAGS="$ac_save_CFLAGS"
|
||||||
|
|
||||||
|
|
|
@ -1076,12 +1076,6 @@
|
||||||
/* Define to 1 if you have the `vsnprintf' function. */
|
/* Define to 1 if you have the `vsnprintf' function. */
|
||||||
#undef HAVE_VSNPRINTF
|
#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 <X11/extensions/shape.h> header file. */
|
/* Define to 1 if you have the <X11/extensions/shape.h> header file. */
|
||||||
#undef HAVE_X11_EXTENSIONS_SHAPE_H
|
#undef HAVE_X11_EXTENSIONS_SHAPE_H
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,7 @@
|
||||||
static inline int ptrace(int req, ...) { errno = EPERM; return -1; /*FAIL*/ }
|
static inline int ptrace(int req, ...) { errno = EPERM; return -1; /*FAIL*/ }
|
||||||
#endif /* HAVE_SYS_PTRACE_H */
|
#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 )
|
static int handle_child_status( struct thread *thread, int pid, int status, int want_sig )
|
||||||
{
|
{
|
||||||
if (WIFSTOPPED(status))
|
if (WIFSTOPPED(status))
|
||||||
|
@ -130,20 +130,20 @@ static int handle_child_status( struct thread *thread, int pid, int status, int
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* wait4 wrapper to handle missing __WALL flag in older kernels */
|
/* waitpid 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 )
|
static inline pid_t waitpid_wrapper( pid_t pid, int *status, int options )
|
||||||
{
|
{
|
||||||
#ifdef __WALL
|
#ifdef __WALL
|
||||||
static int wall_flag = __WALL;
|
static int wall_flag = __WALL;
|
||||||
|
|
||||||
for (;;)
|
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;
|
if (ret != -1 || !wall_flag || errno != EINVAL) return ret;
|
||||||
wall_flag = 0;
|
wall_flag = 0;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
return wait4( pid, status, options, usage );
|
return waitpid( pid, status, options );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ void sigchld_callback(void)
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
if (!(pid = wait4_wrapper( -1, &status, WUNTRACED | WNOHANG, NULL ))) break;
|
if (!(pid = waitpid_wrapper( -1, &status, WUNTRACED | WNOHANG ))) break;
|
||||||
if (pid != -1)
|
if (pid != -1)
|
||||||
{
|
{
|
||||||
struct thread *thread = get_thread_from_tid( pid );
|
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 */
|
/* 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;
|
int res, status;
|
||||||
|
|
||||||
start_watchdog();
|
start_watchdog();
|
||||||
for (;;)
|
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 (errno == EINTR)
|
||||||
{
|
{
|
||||||
if (!watchdog_triggered()) continue;
|
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 */
|
else if (errno == ECHILD) /* must have died */
|
||||||
{
|
{
|
||||||
thread->unix_pid = -1;
|
thread->unix_pid = -1;
|
||||||
thread->unix_tid = -1;
|
thread->unix_tid = -1;
|
||||||
}
|
}
|
||||||
else perror( "wait4" );
|
else perror( "waitpid" );
|
||||||
stop_watchdog();
|
stop_watchdog();
|
||||||
return 0;
|
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 */
|
if (errno == ESRCH) thread->unix_pid = thread->unix_tid = -1; /* thread got killed */
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (wait4_thread( thread, SIGSTOP )) return 1;
|
if (waitpid_thread( thread, SIGSTOP )) return 1;
|
||||||
resume_after_ptrace( thread );
|
resume_after_ptrace( thread );
|
||||||
error:
|
error:
|
||||||
set_error( STATUS_ACCESS_DENIED );
|
set_error( STATUS_ACCESS_DENIED );
|
||||||
|
|
|
@ -801,7 +801,7 @@ void open_master_socket(void)
|
||||||
if (read( sync_pipe[0], &dummy, 1 ) == 1) _exit(0);
|
if (read( sync_pipe[0], &dummy, 1 ) == 1) _exit(0);
|
||||||
|
|
||||||
/* child terminated, propagate exit status */
|
/* child terminated, propagate exit status */
|
||||||
wait4( pid, &status, 0, NULL );
|
waitpid( pid, &status, 0 );
|
||||||
if (WIFEXITED(status)) _exit( WEXITSTATUS(status) );
|
if (WIFEXITED(status)) _exit( WEXITSTATUS(status) );
|
||||||
_exit(1);
|
_exit(1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -251,7 +251,6 @@ utime
|
||||||
vfprintf
|
vfprintf
|
||||||
vsnprintf
|
vsnprintf
|
||||||
vsprintf
|
vsprintf
|
||||||
wait4
|
|
||||||
write
|
write
|
||||||
y0
|
y0
|
||||||
y1
|
y1
|
||||||
|
|
Loading…
Reference in New Issue