13.24 ptrace (4164)

This procedure implements the “ptrace” system call, #26.

4168:

“u.u_arg[2]” corresponds to the first parameter in the “C” program calling sequence. If this is zero, a child process is asking to be traced by its parent, so set the “STRC” flag and return.

Note that this code handles the only explicit action the child process is asked to take with respect to tracing. There is no real reason why even this action should be taken by the child process and not by the parent process. From a security point of view it is most probably desirable that a child process should only be traceable if it gives its permission. On the other hand, if the child asks to be traced and is then ignored by the parent, the child process may be blocked indefinitely. Perhaps the best solution would be for the “STRC” flag to be set only after explicit action by both the parent and the child.

4172:

Search the “proc” table looking for a process which: is stopped; matches the given process identifying number; is a child of the current process;

4181:

Wait for the “ipc” structure to become available if it is currently in use;

4183:

Copy the parameters into “ipc” ...

4187:

reset the “SWTED” flag, and ...

4188:

return the child to a “ready to run” state;

4189:

Sleep until “ipc.ip_req” is nonpositive (4212);

4191:

Extract a value that is to be returned to the parent process, check for errors, unlock “ipc” and “wake up” any processes waiting for “ipc”.

Note that the “sleeps” on lines 4182, 4190 are for essentially different reasons, and could be differentiated to good effect by replacing “&ipc” by “&ipc.ip_req” on lines 4190 and 4213.