3

I have a CLI script written in PHP that I am trying to debug with XDebug. The debugger is working, as I can step through the code as it initializes, but it breaks down after the process forks, becomes a daemon, and lets the original process exit. My theory is the XDebug socket is closing when the initial process terminates, which leaves the daemon and any processes it forks without an open socket to my XDebug listener.

Database connections can be reconnected or even created after the fork, but XDebug appears to have no such option in their function list. Can the XDebug socket survive the initial process exiting or be reestablished after the a call to pcntl_fork()? Is there any workaround for this?

3
  • I don't think Xdebug was intended to still be alive after the initial process terminates. The question here is why do you need to use pcntl_fork(). Commented Mar 10, 2016 at 20:35
  • Because the script is a daemon that handles special requests on a listening socket. Everything works fine, this is not a case of "use cron instead," except the debugger seems to be oblivious to the pcntl_fork() (just like DB extensions) but does not offer a way to manually reopen the connection. Commented Mar 10, 2016 at 20:44
  • This can maybe help you stackoverflow.com/questions/17648097/… Commented Mar 10, 2016 at 20:47

1 Answer 1

2

No, Xdebug does not handle sockets that span multiple processes. Your theory is sort of right. A socket simply can't be easily duplicated upon a fork, and Xdebug does not handle this currently. A socket is also closed when a process ends.

There is an issue (https://bugs.xdebug.org/view.php?id=938), on which you commented. It is possible to fix this—I've done a similar thing with the old MongoDB extension—but it's not high on my priority list.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.