Home > Software design >  DEBUGGER: Attaching after process <pid1> fork to child process <pid2>
DEBUGGER: Attaching after process <pid1> fork to child process <pid2>

Time:03-17

When using the ruby debug gem, I often see the following output printed out:

DEBUGGER: Attaching after process <pid1> fork to child process <pid2>

where <pid1> is a parent process id like 12345 and <pid2> is a newly forked child process id, like 55555.

What is going on here? Has it got anything to do with connecting to application preloaders like Spring or Zeus?

CodePudding user response:

It's coming from this code here: https://github.com/ruby/debug/blob/4af8c25140a7a672db852954b6a1733b3169b608/lib/debug/session.rb#L2129-L2162

What's happening is that your main Ruby process is forking off a new process, and it's telling you that the debugger is attaching to the newly-created child process with process id <pid2>, so that it too can break for debugging events.

In my case, this was happening when calling visit <url> in an automated test which, due to having a Capybara Selenium webdriver, creates a new child process to spin up a Chrome process to render the request's HTML.

By default, the ruby debug gem will attach to both the parent and child processes. But you can override to only activate the debugger for either the child or parent by using the RUBY_DEBUG_FORK_MODE environment variable.

To be clear, it has nothing to do with application preloaders like Spring or Zeus.

  • Related