exec(2) by a debugged process

Marc Maathuis mm at chorus.fr
Wed Jan 23 00:01:14 AEST 1991


When a process that is debugged (traced), i.e. which has made
a ptrace(0,...) system call, makes an exec(2), it will be  stopped
before executing the first instruction, in order to pass control
to the debugger. This allows the debugger to insert breakpoints
in the text of the debuggee.

In fact, when UNIX is handling the exec(2), it
    1/ posts a SIGTRAP to the process, *and*
    2/ sets the trace bit in the status register.
It seems to me that either one these 2 is sufficient to stop
the debuggee and pass control to the debugger. In fact the debugger
gets control twice.

My question:
why both posting SIGTRAP *and* putting the process in trace mode?

Please reply by email, since I usually don't read this group.
I'll summarize if interest.

Marc
--

--
Marc Maathuis                         Tel +33 1 30 64 82 57 (direct)
Chorus systemes                       Fax +33 1 30 57 00 66
6, avenue Gustave Eiffel              E-mail: mm at chorus.fr (Internet)
F-78182 St. Quentin en Yvelines Cedex
France



More information about the Comp.unix.questions mailing list