[RFC PATCH] conhost: Register as a system process.

Jacek Caban jacek at codeweavers.com
Thu Nov 5 13:52:26 CST 2020


On 11/4/20 11:34 PM, Torge Matthies wrote:
> Hello Jacek, thank you very much for your reply!
> 
> On 11/4/20 6:04 PM, Jacek Caban wrote:
>> Hi Torge,
>>
>>
>> On 11/2/20 10:34 PM, Torge Matthies wrote:
>>> I understand that using Wine-internal functions is not supported, however
>>> the desired behavior seems hard if not impossible to implement otherwise.
>>
>> You should be able to achieve that by implementing your application as a
>> Windows service.
> I tried that a long time ago, but it turned out that Wine does not wait for
> services to finish starting up before starting the game process, so the proxy
> was usually only ready when it was too late, and the game had already given
> up on connecting to Discord at that point.


wineboot waits until all autostart services are started, see 
SVCCTL_STARTED_EVENT event handing. You just need to make sure to create 
the pipe before signaling service as started.

>> For a quick workaround would be to call FreeConsole() in your
>> application. This way console will become unused and conhost will exit
>> earlier.
> This was also one of the first things I tried when I noticed the change in
> behavior. It did not work for some reason, the conhost process stayed around.
> The process also daemonizes itself after becoming ready to accept
> connections, by CreateProcess'ing its executable and in the child process
> signaling the parent process to exit after becoming ready. But I have also
> tried with this functionality disabled and got the same conhost process.

conhost should terminate in that case, assuming that no process is 
connected to it anymore. If it doesn't, that's a bug. I have some fixes 
planned for that area.

>> If you wrap execution with a script, you could also make sure that none
>> of std handles (in, out, err) is a terminal. In this case conhost will
>> not be created in the first place.
> This works, but it's not ideal since I would like to print log messages to
> stdout/stderr. This has also been broken for some time with the daemonize
> option enabled, and I've actually been meaning to e-mail you about that.
> But I'm bad at initiating conversation, so I never sent that e-mail...
> Do you happen to know why I can't write to stdout/stderr in a child process?


You can also pipe output so that it's not a terminal, something like 
|cat should do.


Jacek



More information about the wine-devel mailing list