I'm trying to write a simple de* w/the 5.1 procfs, and I cannot
get my child to stop in the execve call. I was hoping someone could
shed some light on if there's either bugginess w/that procfs, or I am
simply not doing something I ought to be. My primary problem seems to
be getting the child to stop executing.
The basic flow of the program is thus:
- child opens it's own ctl file until it has an exclusive write fd
- child loads it's syscall list from sysent
- child sets up a sysset_t struct w/the syscalls "execve" and
- child writes a PCSEXIT command to the ctl file, with the sysset_t
- child execve's the argument
From what I've read the child should now be halted, waiting for the
parent to set breakpoints, etc, and issue the PC_RUN command
- parent opens the status file for the child process
- parent opens_with_retry the ctl file for the child
- parent checks to see if child is stopped
- if not, parent issues a PCWSTOP command
At this point, the child should be stopped, since the parent said to
until it is stopped.
- parent reads the status file to determine if the child is stopped
Here's where the problem arises. The child's pstat.pr_lwp.pr_flags
never report PR_STOPPED, they always report PR_NOREGS! What gives?
It turns out the child never stops for the parent. If I run this
program a dozen times, half the time the child will beat the parent to
even issuing the PCWSTOP, and go ahead and execute its argument, so
it's a race. My problem is somewhere in the way I'm telling the child
to stop in execve. But I can't figure what I'm doing wrong.
I could send someone some code, if they think they can help, the main
control block is just shy of 300 lines w/all the debugging messages I
have in there.
If anyone out there has experience programming the procfs interface, I
would deeply appreciate any help here!!