0

I have Apache server on my windows machine.

From PHP script I start .bat file using exec command(synchronously!).

From my batch script I run another executable(WinDBG). I run it asynchronously(using cmd start command) wait some time and kill if it is still running.

If I run .bat script from cmd it works as planned(asynchronously). But if script is started from PHP exec command "start" works synchronously. And it is the same code.

I think that the problem is that PHP script run as a windows service. And therefore start work synchronously.

I should start WinDBG asynchronously to have ability terminate it

thor
  • 21,418
  • 31
  • 87
  • 173
Yuriy Pryyma
  • 574
  • 6
  • 18
  • PHP won't return until the standard output handle (and perhaps the standard error handle?) is closed. That won't happen so long as a descendant process exists, unless you take steps to prevent the handle from being inherited or to explicitly close it. You could try redirecting the output to NUL, as per http://stackoverflow.com/a/7693202/886887, but I'm [no longer sure that works](https://stackoverflow.com/questions/36091748/how-do-i-use-the-start-command-without-inheriting-handles-in-the-child-process). – Harry Johnston May 14 '16 at 04:02
  • Harry Johnston, the thing is that I do not want batch script started from php to run asynk. I want start process from my batch file and do not wait for it to terminate – Yuriy Pryyma May 14 '16 at 08:15
  • Are you sure that it is the batch file that is waiting and not PHP? That would only happen if the application failed to start properly, perhaps because of a missing DLL dependency or a problem with the permissions on the executable. – Harry Johnston May 14 '16 at 21:32

0 Answers0