Commit 1841f311 authored by Russ Cox's avatar Russ Cox

acid fixes etc. still not perfect.

R=r
DELTA=764  (694 added, 38 deleted, 32 changed)
OCL=15285
CL=15395
parent db9002f1
...@@ -415,5 +415,6 @@ void detachproc(Map *m); ...@@ -415,5 +415,6 @@ void detachproc(Map *m);
int procnotes(int pid, char ***pnotes); int procnotes(int pid, char ***pnotes);
char* proctextfile(int pid); char* proctextfile(int pid);
int procthreadpids(int pid, int **thread); int procthreadpids(int pid, int **thread);
char* procstatus(int);
Maprw fdrw; Maprw fdrw;
This diff is collapsed.
...@@ -49,8 +49,8 @@ struct user_regs_struct { ...@@ -49,8 +49,8 @@ struct user_regs_struct {
unsigned long rip,cs,eflags; unsigned long rip,cs,eflags;
unsigned long rsp,ss; unsigned long rsp,ss;
unsigned long fs_base, gs_base; unsigned long fs_base, gs_base;
unsigned long ds,es,fs,gs; unsigned long ds,es,fs,gs;
}; };
static int static int
isstopped(int pid) isstopped(int pid)
...@@ -160,7 +160,7 @@ detachproc(Map *m) ...@@ -160,7 +160,7 @@ detachproc(Map *m)
free(m); free(m);
} }
/* /proc/pid/stat contains /* /proc/pid/stat contains
pid pid
command in parens command in parens
0. state 0. state
...@@ -289,41 +289,25 @@ ctlproc(int pid, char *msg) ...@@ -289,41 +289,25 @@ ctlproc(int pid, char *msg)
if(strcmp(msg, "startstop") == 0){ if(strcmp(msg, "startstop") == 0){
if(ptrace(PTRACE_CONT, pid, 0, 0) < 0) if(ptrace(PTRACE_CONT, pid, 0, 0) < 0)
return -1; return -1;
goto waitstop; return waitstop(pid);
} }
if(strcmp(msg, "sysstop") == 0){ if(strcmp(msg, "sysstop") == 0){
if(ptrace(PTRACE_SYSCALL, pid, 0, 0) < 0) if(ptrace(PTRACE_SYSCALL, pid, 0, 0) < 0)
return -1; return -1;
goto waitstop; return waitstop(pid);
} }
if(strcmp(msg, "stop") == 0){ if(strcmp(msg, "stop") == 0){
if(kill(pid, SIGSTOP) < 0) if(kill(pid, SIGSTOP) < 0)
return -1; return -1;
goto waitstop; return waitstop(pid);
} }
if(strcmp(msg, "step") == 0){ if(strcmp(msg, "step") == 0){
if(ptrace(PTRACE_SINGLESTEP, pid, 0, 0) < 0) if(ptrace(PTRACE_SINGLESTEP, pid, 0, 0) < 0)
return -1; return -1;
goto waitstop; return waitstop(pid);
}
if(strcmp(msg, "waitstop") == 0){
waitstop:
if(isstopped(pid))
return 0;
for(;;){
p = waitpid(pid, &status, WUNTRACED|__WALL);
if(p <= 0){
if(errno == ECHILD){
if(isstopped(pid))
return 0;
}
return -1;
}
/*fprint(2, "got pid %d status %x\n", pid, status); */
if(WIFEXITED(status) || WIFSTOPPED(status))
return 0;
}
} }
if(strcmp(msg, "waitstop") == 0)
return waitstop(pid);
if(strcmp(msg, "start") == 0) if(strcmp(msg, "start") == 0)
return ptrace(PTRACE_CONT, pid, 0, 0); return ptrace(PTRACE_CONT, pid, 0, 0);
werrstr("unknown control message '%s'", msg); werrstr("unknown control message '%s'", msg);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment