+2009-01-17 Denys Vlasenko <dvlasenk@redhat.com>
+
+ * process.c: Add a comment. No code changes.
+ * strace.c (collect_stopped_tcbs): Stop reversing list of stopped
+ tcp's. I'm not totally convinced it is crucial, but this is surely
+ fits the concept of "least surprise".
+ Do not collect TCB_SUSPENDED tcp's (this is closer to how
+ it was before).
+ (handle_stopped_tcbs): Remove the code to reject TCB_SUSPENDED tcp's,
+ it's done earlier now. In an unobvious way, this was causing
+ SIGSTOPs from freshly attached children to be misinterpreted.
+
2009-01-14 Denys Vlasenko <dvlasenk@redhat.com>
* linux/bfin/syscallent.h: sys_futex has 6 parameters, not 5.
struct rusage ru;
struct rusage* ru_ptr = cflag ? &ru : NULL;
int wnohang = 0;
- struct tcb *found_tcps = NULL;
+ struct tcb *found_tcps;
+ struct tcb **nextp = &found_tcps;
#ifdef __WALL
int wait4_options = __WALL;
#endif
tcp->stime = ru.ru_stime;
#endif
}
+ if (tcp->flags & TCB_SUSPENDED) {
+ /*
+ * Apparently, doing any ptrace() call on a stopped
+ * process, provokes the kernel to report the process
+ * status again on a subsequent wait(), even if the
+ * process has not been actually restarted.
+ * Since we have inspected the arguments of suspended
+ * processes we end up here testing for this case.
+ */
+ continue;
+ }
+
tcp->wait_status = status;
#ifdef LINUX
- tcp->next_need_service = found_tcps;
- found_tcps = tcp;
+ /* It is important to not invert the order of tasks
+ * to process. For one, alloc_tcb() above picks newly forked
+ * threads in some order, processing of them and their parent
+ * should be in the same order, otherwise bad things happen
+ * (misinterpreted SIGSTOPs and such).
+ */
+ *nextp = tcp;
+ nextp = &tcp->next_need_service;
wnohang = WNOHANG;
#endif
#ifdef SUNOS4
*/
break;
#endif
- } /* while (1) - collecting all stopped/exited tracees */
+ }
- return tcp;
+ *nextp = NULL;
+ return found_tcps;
}
static int
int pid;
int status;
- if (tcp->flags & TCB_SUSPENDED) {
- /*
- * Apparently, doing any ptrace() call on a stopped
- * process, provokes the kernel to report the process
- * status again on a subsequent wait(), even if the
- * process has not been actually restarted.
- * Since we have inspected the arguments of suspended
- * processes we end up here testing for this case.
- */
- continue;
- }
-
outf = tcp->outf;
status = tcp->wait_status;
pid = tcp->pid;