@jacek sorry I somehow missed your comment on the other MR
I'm not sure I like the patch as is... - I wonder if kernelbase.CtrlRoutine should only be called for CUI programs... MSDN doc is as usual imprecise (it speaks about all descendants, and all descendants attached to the same console) - quick test show that a GUI process isn't killed by GenerateConsoleCtrlEvent + tested parent + console, cp_flags=0 and pgid = parent's pgid + tested parent + console, cp_flags=detached + new group, pgid = child.id => it doesn't fully anwser whether CtrlRoutine is called or not for GUI - it assumes pgid are inherited for gui (but we don't have proper tests AFAICT)
moreover it means that we'd want two different behaviors when receiving SIGINT (whether it's a genuine unix signal or one sent by the server if we follow the tests result above) perhaps, the solution would be in the default_ctrl_handler to only terminate the program if attached to a console, or in the program group of a unix console
remark: Wine unix console is the sole case where launching a GUI program from command line doesn't return immediately to prompt (native & builtin cmd implementation only wait on CUI programs completion). But that's conform to unix behavior.
note: I'm not even sure tweeking with setsid whould be useful as anyway the unix console is in raw mode, so only conhost regenerates the signals