getting children to stop w/procfs

getting children to stop w/procfs

Post by mart » Wed, 03 Apr 2002 11:33:59



Hello,

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:

- fork

   - 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
"ra_execve"
   - child writes a PCSEXIT command to the ctl file, with the sysset_t
attached
   - 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
wait
 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!!

Thanks,
Martin

 
 
 

1. Getting a child and child's child process-id

 Why not just have the parent fork twice ??? Saves a lot of trouble ...
--


#  Have you read your Book In Basic Life Education today ? You should !!  #
#  Any views I express are not necessarily those of Brighton Polytechnic  #
###################### "surivorter erutangis a ma I" ######################

2. Problems with Booting Fedora Core 4 with Raid 1

3. Gateway Astro Installation Issue

4. signals: stop child, parent told child died !

5. hardware question

6. kill -STOP <PID#> -> "child process has been stopped, restarting." ?

7. Modules, gcc2_compiled. undefined

8. Supervising non-child processes w/wo procfs

9. Stop parent if child dies

10. How to stop child process?

11. stop child process

12. How do i suspend & stop & resume a process inside child()?