- extern int auto_solib_add;
-
- int debugger_pid;
- int status;
- char pid_spelling[100]; /* Arbitrary but sufficient length. */
-
- /* This semaphore is used to coordinate the two debuggers' handoff
- of CHILD_PID. The original debugger will detach from CHILD_PID,
- and then the clone debugger will attach to it. (It must be done
- this way because on some targets, only one process at a time can
- trace another. Thus, the original debugger must relinquish its
- tracing rights before the clone can pick them up.)
- */
-#define SEM_TALK (1)
-#define SEM_LISTEN (0)
- int handoff_semaphore[2]; /* Original "talks" to [1], clone "listens" to [0] */
- int talk_value = 99;
- int listen_value;
-
- /* Set debug_fork then attach to the child while it sleeps, to debug. */
- static int debug_fork = 0;
-
- /* It is generally good practice to flush any possible pending stdio
- output prior to doing a fork, to avoid the possibility of both the
- parent and child flushing the same data after the fork. */
-
- gdb_flush (gdb_stdout);
- gdb_flush (gdb_stderr);
-
- /* Open the semaphore pipes.
- */
- status = pipe (handoff_semaphore);
- if (status < 0)
- error ("error getting pipe for handoff semaphore");