From: Wichert Akkerman Date: Wed, 28 Mar 2001 14:40:14 +0000 (+0000) Subject: use __WALL for wait4 if we can X-Git-Tag: v4.5.18~1066 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2f1d87e74ff68004b99901f964a1cbab89da09db;p=strace use __WALL for wait4 if we can --- diff --git a/ChangeLog b/ChangeLog index 967d64a8..666775a0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2001-03-28 Wichert Akkerman + + * strace.c: use __WALL as wait4 flag if it exists so we can properly + trace threaded programs + 2001-03-27 John Hughes * aclocal.m4: add check for endianness of long long. diff --git a/strace.c b/strace.c index 0e9242b1..de2d5665 100644 --- a/strace.c +++ b/strace.c @@ -1595,13 +1595,36 @@ trace() struct tcb *tcp; #ifdef LINUX struct rusage ru; +#ifdef __WALL + static int wait4_options = __WALL; +#endif #endif /* LINUX */ while (nprocs != 0) { if (interactive) sigprocmask(SIG_SETMASK, &empty_set, NULL); #ifdef LINUX +#ifdef __WALL + pid = wait4(-1, &status, wait4_options, cflag ? &ru : NULL); + if ((wait4_options & __WALL) && errno == EINVAL) { + /* this kernel does not support __WALL */ + wait4_options &= ~__WALL; + errno = 0; + pid = wait4(-1, &status, wait4_options, + cflag ? &ru : NULL); + } + if (!(wait4_options & __WALL) && errno == ECHILD) { + /* most likely a "cloned" process */ + pid = wait4(-1, &status, __WCLONE, + cflag ? &ru : NULL); + if (pid == -1) { + fprintf(stderr, "strace: clone wait4 " + "failed: %s\n", strerror(errno)); + } + } +#else pid = wait4(-1, &status, 0, cflag ? &ru : NULL); +#endif /* __WALL */ #endif /* LINUX */ #ifdef SUNOS4 pid = wait(&status);