2002-12-17 Roland McGrath <roland@redhat.com>
* strace.c (detach) [LINUX]: Use __WALL (or a second try with __WCLONE)
in wait after sending SIGSTOP.
diff --git a/strace.c b/strace.c
index 67e832d..9f2a861 100644
--- a/strace.c
+++ b/strace.c
@@ -1066,11 +1066,34 @@
}
else {
for (;;) {
- if (waitpid(tcp->pid, &status, 0) < 0) {
- if (errno != ECHILD)
+#ifdef __WALL
+ if (wait4(tcp->pid, &status, __WALL, NULL) < 0) {
+ if (errno == ECHILD) /* Already gone. */
+ break;
+ if (errno != EINVAL) {
perror("detach: waiting");
- break;
+ break;
+ }
+#endif /* __WALL */
+ /* No __WALL here. */
+ if (waitpid(tcp->pid, &status, 0) < 0) {
+ if (errno != ECHILD) {
+ perror("detach: waiting");
+ break;
+ }
+#ifdef __WCLONE
+ /* If no processes, try clones. */
+ if (wait4(tcp->pid, &status, __WCLONE,
+ NULL) < 0) {
+ if (errno != ECHILD)
+ perror("detach: waiting");
+ break;
+ }
+#endif /* __WCLONE */
+ }
+#ifdef __WALL
}
+#endif
if (!WIFSTOPPED(status)) {
/* Au revoir, mon ami. */
break;