Re: Why does cli_set_process_title sometimes change the wrong process'title?

[email protected] ("Christoph M. Becker") Sun, 12 Apr 2020 15:09:47 +0200
Newsgroups php.windows
Message-ID <[email protected]>
On 12.04.2020 at 11:29, [email protected] wrote:

> I currently only run PHP on Windows, so I have no idea if the same thing=
 happens on the other platforms.
>
> I frequently call cli_set_process_title() in my CLI PHP scripts to set t=
he "process title". Normally, there are no problems at all.
>
> However, on at least two separate occasions, the last time yesterday, so=
mething very strange happened at some unknown point: one of the cli_set_pr=
ocess_title() calls changed the process title of a completely different pr=
ocess/window: the PHP built-in webserver one!
>
> I start both the built-in PHP webserver and my own PHP CLI scripts with =
.bat files. My CLI PHP scripts end up in the cmd.exe group in the Taskbar.
>
> How can this be technically and logically possible? Is it a known issue?=
 Is it known why and when this happens? I have no idea how I'd reproduce i=
t since it rarely does this, but once it has done so, the process/window i=
n question keeps its title forever, until I close it and restart it. (Whic=
h of course spawns a new process.)
>
> This really frustrates me, because it's such a weird bug/glitch.

cli_set_process_title() basically just calls SetConsoleTitle()[1], so I
can't see why that would affect an unrelated console window.  More
information regarding your environment (which Windows version? which PHP
version and variant?) and also about how you start these processes
(`start`, `cmd /c` etc.) might be helpful.

[1] <https://docs.microsoft.com/en-us/windows/console/setconsoletitle>

=2D-
Christoph M. Becker