Using Sun WorkShop

Debugging a Child Process

When a process forks a child process, you can choose to debug the parent process, the child process, or both. You can also override the normal deletion of all breakpoints from the forked process.

The Sampling Collector is disabled for a forked process.

If you consistently follow the same process across executions, you can bypass the Follow Fork dialog box by designating the default action you want to take.

To set the default for a forked process:

  1. From the Debugging window, choose Debug > Debugging Options.

  2. Choose Category > Forks and Threads.

  3. Click the appropriate radio button:

      Parent The fork is ignored and the parent is followed. This is the default behavior.
     Child Debugging switches to the forked child. The process ID of the current process changes to the child's process ID. The parent continues as if it had been detached, and the child process is suspended as if it had been attached. Use Go or Step Into to execute the child process.
     Both A second debugging session is launched to debug the child process, and becomes the current session. The parent's debugging session remains as an active process. The child process is suspended as if it had been attached.
     Ask User Whenever a fork is detected, the Follow Fork dialog box opens, allowing you to choose between the parent, the child, or both processes at the same time. You can examine the state of your program each time to see which fork you want to follow.

  4. Click OK to apply your choices to the current session, or click Save As Defaults and then click OK to use them as the new defaults.

The selected action occurs whenever the process executes fork().

To allow the child to inherit the parent's breakpoints when the new fork will not execute a different process:

  1. From the Debugging window, choose Debug > Debugging Options.

  2. Choose Category > Forks and Threads.

  3. At Child process inherits parent's breakpoints, click the checkbox to enable it.

  4. Click OK to apply your choices to the current session, or click Save As Defaults and then click OK to save your choices as the new defaults.