linux - How to control the thread of child process -


i'm trying implement following function in debugger: want use debugger control thread in process being debugged.
debugger parent process , uses ptrace() function debug child process, don't know how control thread (other main) of child process parent process. want make target thread halt or continue. there way this? code below

#include<pthread.h> #include<stdio.h>  void *runner(void *param); int main(int argc,char *argv[]) {     int pid;     pthread_t tid;     pthread_attr_t attr;     pid=fork();     if(pid==0){         pthread_attr_init(&attr);         pthread_create(&tid,&attr,runner,null);         pthread_join(tid,null);         printf("child value=%d",value);     }     else if(pid>0){         wait(null);         printf("parent value=%d",value);     } }   void *runner(void *param){     int count = 0;     while(1)     {           printf("%d\n",count);          count++;          sleep(1);     }     pthread_exit(0); } 

in code, child process creates thread print numbers in loop. can use function ptrace() in parent process control thread? make suspend or continue?


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -