lkml.org 
[lkml]   [2004]   [Oct]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subjectptrace bug in -rc2+
  Hi,

The introduction of the new TASK_TRACED state in 2.6.9-rc2 changed the
behavior of the kernel in a IMHO buggy way. Sending a SIGKILL to a
process which is traced _and_ stopped doesn't work any more. user mode
linux kernels do that on shutdown, thats why I ran into this.

Below is a short test app which shows the behavior. On 2.6.9-rc2+ the
last waitpid() call blocks forever, on older kernels it doesn't ...

Gerd

==============================[ cut here ]==============================
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <sys/ptrace.h>
#include <sys/types.h>
#include <sys/wait.h>

int main(int argc, char *argv[])
{
int child,rc,status;

child = fork();
if (0 == child) {
fprintf(stderr,"[child] ptrace me ...\n");
ptrace(PTRACE_TRACEME);
fprintf(stderr,"[child] exec sleep 10 ...\n");
execlp("sleep", "sleep", "10", NULL);
perror("execlp");
exit(1);
}

sleep(1);
fprintf(stderr,"kill %d,STOP ...\n",child);
kill(child,SIGSTOP);
fprintf(stderr,"waitpid %d...\n",child);
rc = waitpid(child,&status,WUNTRACED);
fprintf(stderr,"%s: rc=%d status=%s%s%s termsig=%d\n",__FUNCTION__,rc,
WIFEXITED(status) ? "exit" : "",
WIFSIGNALED(status) ? "signal" : "",
WIFSTOPPED(status) ? "stopped" : "",
WTERMSIG(status));

sleep(1);
fprintf(stderr,"kill %d,KILL ...\n",child);
kill(child,SIGKILL);
fprintf(stderr,"waitpid %d...\n",child);
rc = waitpid(child,&status,WUNTRACED);
fprintf(stderr,"%s: rc=%d status=%s%s%s termsig=%d\n",__FUNCTION__,rc,
WIFEXITED(status) ? "exit" : "",
WIFSIGNALED(status) ? "signal" : "",
WIFSTOPPED(status) ? "stopped" : "",
WTERMSIG(status));

exit(0);
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:07    [W:0.024 / U:6.592 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site