I have used ptrace
to force a thread within another process to call
sys_clone
and create a new thread with pid pid
, with the clone flags CLONE_FILES
,
CLONE_FS
, CLONE_IO
, CLONE_PTRACE
, CLONE_SIGHAND
, CLONE_THREAD
and
CLONE_VM
.
As I understand from the ptrace
man-page, waitpid() is valid on children
processes and ptrace'd processes. However, the following code in my program
succeeds:
assert(ptrace(PTRACE_CONT, pid, NULL, NULL) != -1);
assert(waitpid(pid, NULL, WSTOPPED) == -1);
printf("error: %s\n", strerror(errno));
Output:
error: No child processes
Why could this be? I have checked that when the ptrace is removed, the child thread terminates on a breakpoint instruction (0xcc).