[BUG] strace -f hangs if child is waiting for parent
Heiko Carstens
heiko.carstens at de.ibm.com
Mon Jan 17 05:17:08 UTC 2005
Hi all again,
the following piece of code lets strace hang when traced with the
follow-fork option.
#include <signal.h>
#include <wait.h>
#include <sys/types.h>
pid_t child;
void al(int sig)
{
kill (child, SIGTERM);
}
int main (int argc, char **argv)
{
int pid, status;
child = fork();
if (child == 0)
pause();
else {
signal (SIGALRM, al);
alarm(5);
wait(0);
}
}
Reason for the hang is that strace sets the TCB_SUSPENDED flag in
internal_wait and therefore the task's state doesnt change from
TASK_TRACED. When finally the alarm signal gets delivered to the
parent it will just have another signal pending but the kernel won't
wake it up due to its state.
And then things won't continue.
A quick solution would be to not set the TCB_SUSPENDED flag in this
case as well, but for sure it would break all the other cases where
this flag would be needed.
Roland, considering the changelog you fixed a lot of stuff already in
internal_wait. Do you have any idea how to fix this one without
breaking anything else?
Thanks,
Heiko
More information about the Strace-devel
mailing list