Program does not stop when windows terminal is closed. #18023

Closed
opened 2026-01-31 06:01:31 +00:00 by claunia · 8 comments
Owner

Originally created by @kotenok2000 on GitHub (Jul 24, 2022).

Windows Terminal version

1.14.1963.0

Windows build number

10.0.22000.795

Other Software

doecm 1.10
https://mklasson.com/factors/index.php
https://mklasson.com/doecm_110_win.zip

Steps to reproduce

Unpack doecm_110_win.zip
run run.bat
close windows terminal window
ecm.exe gets killed. Doecm process doesn't get killed and tries to spawn ecm.exe
each time doecm tries to spawn ecm.exe cmd.exe fails with 0xc0000142 error

Expected Behavior

No response

Actual Behavior

When i close windows terminal window ecm.exe gets killed, but doecm.exe process doesn't get killed and tries to spawn ecm.exe
each time doecm tries to spawn ecm.exe cmd.exe fails with 0xc0000142 error

Originally created by @kotenok2000 on GitHub (Jul 24, 2022). ### Windows Terminal version 1.14.1963.0 ### Windows build number 10.0.22000.795 ### Other Software doecm 1.10 https://mklasson.com/factors/index.php https://mklasson.com/doecm_110_win.zip ### Steps to reproduce Unpack doecm_110_win.zip run run.bat close windows terminal window ecm.exe gets killed. Doecm process doesn't get killed and tries to spawn ecm.exe each time doecm tries to spawn ecm.exe cmd.exe fails with 0xc0000142 error ### Expected Behavior _No response_ ### Actual Behavior When i close windows terminal window ecm.exe gets killed, but doecm.exe process doesn't get killed and tries to spawn ecm.exe each time doecm tries to spawn ecm.exe cmd.exe fails with 0xc0000142 error
claunia added the Issue-BugNeeds-Tag-FixProduct-TerminalArea-Remoting labels 2026-01-31 06:01:31 +00:00
Author
Owner

@DHowett commented on GitHub (Jul 25, 2022):

Does this happen outside of Windows Terminal?

@DHowett commented on GitHub (Jul 25, 2022): Does this happen outside of Windows Terminal?
Author
Owner

@kotenok2000 commented on GitHub (Jul 25, 2022):

It doesn't happen when i run it in conhost

@kotenok2000 commented on GitHub (Jul 25, 2022): It doesn't happen when i run it in conhost
Author
Owner

@zadjii-msft commented on GitHub (Jul 26, 2022):

run.bat

start /B /LOW /WAIT doecm.exe %1 %2 %3 %4 %5 %6 %7 %8 %9

There's a int main( int argc, char ** argv ) { in the doecm.cc file, which makes me think this is a console subsystem application, not a windows subsystem one.

From the included README:

One quirk of the "start" program used to set priority in run.bat is that it
disables ctrl-c. Ctrl-break still works though.

start /?

Starts a separate window to run a specified program or command.

START ["title"] [/D path] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED]
      [/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL]
      [/NODE <NUMA node>] [/AFFINITY <hex affinity mask>] [/WAIT] [/B]
      [/MACHINE <x86|amd64|arm|arm64>][command/program] [parameters]
...
    B           Start application without creating a new window. The
                application has ^C handling ignored. Unless the application
                enables ^C processing, ^Break is the only way to interrupt
                the application.

So, doecm.exe gets a copy of the current console handles, not a new set of handles.

Unfortunately, there's not a lot of other source there to go off of. Seems like the Terminal is closing out the console handle, but for whatever reason, doecm.exe doesn't have anything to check if the console handle is still open and close itself. So it goes on, tries to spawn an ecm.exe, and that can't inherit the console (because there is no console), and that throws the 0xc0000142. That's mostly conjecture, based off the little bit of source code included.

We may need the maintainer to hop in here to help ID what's going on...

@zadjii-msft commented on GitHub (Jul 26, 2022): `run.bat` ```bat start /B /LOW /WAIT doecm.exe %1 %2 %3 %4 %5 %6 %7 %8 %9 ``` There's a `int main( int argc, char ** argv ) {` in the doecm.cc file, which makes me think this is a console subsystem application, not a windows subsystem one. From the included README: > One quirk of the "start" program used to set priority in run.bat is that it > disables ctrl-c. Ctrl-break still works though. `start /?` ``` Starts a separate window to run a specified program or command. START ["title"] [/D path] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED] [/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL] [/NODE <NUMA node>] [/AFFINITY <hex affinity mask>] [/WAIT] [/B] [/MACHINE <x86|amd64|arm|arm64>][command/program] [parameters] ... B Start application without creating a new window. The application has ^C handling ignored. Unless the application enables ^C processing, ^Break is the only way to interrupt the application. ``` So, doecm.exe gets a copy of the current console handles, not a new set of handles. Unfortunately, there's not a lot of other source there to go off of. Seems like the Terminal is closing out the console handle, but for whatever reason, doecm.exe doesn't have anything to check if the console handle is still open and close itself. So it goes on, tries to spawn an `ecm.exe`, and that can't inherit the console (because there is no console), and that throws the 0xc0000142. That's mostly conjecture, based off the little bit of source code included. We may need the maintainer to hop in here to help ID what's going on...
Author
Owner

@ghost commented on GitHub (Jul 30, 2022):

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

@ghost commented on GitHub (Jul 30, 2022): This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for **4 days**. It will be closed if no further activity occurs **within 3 days of this comment**.
Author
Owner

@kotenok2000 commented on GitHub (Jul 30, 2022):

Bump.
I think the bot is buggy. it says that the issue "Needs-Author-Feedback" but in actuality it "Needs-Attention"

@kotenok2000 commented on GitHub (Jul 30, 2022): Bump. I think the bot is buggy. it says that the issue "Needs-Author-Feedback" but in actuality it "Needs-Attention"
Author
Owner

@zadjii-msft commented on GitHub (Aug 10, 2022):

You know, yea that's a bit of a bug. This: image triggered the bot's "we need the author's feedback" routine accidentally.

That being said, we still do need direct insight from the maintainer of doecm here. From what I can see of the source, I would expect closing the terminal (and thereby closing the console) to close this process. It kinda feels like something that needs to be reported to doecm.

I'll give the bot another week, but there's not much more we can investigate here...

@zadjii-msft commented on GitHub (Aug 10, 2022): You know, yea that's a bit of a bug. This: ![image](https://user-images.githubusercontent.com/18356694/184027476-265cfa6a-bc0b-4028-a50a-74925df24ece.png) triggered the bot's "we need the author's feedback" routine accidentally. That being said, we still do need direct insight from the maintainer of `doecm` here. From what I can see of the source, I would expect closing the terminal (and thereby closing the console) to close this process. It kinda feels like something that needs to be reported to doecm. I'll give the bot another week, but there's not much more we can investigate here...
Author
Owner

@kotenok2000 commented on GitHub (Aug 10, 2022):

why does conhost close the process, but windows terminal doesn't?

@kotenok2000 commented on GitHub (Aug 10, 2022): why does conhost close the process, but windows terminal doesn't?
Author
Owner

@lhecker commented on GitHub (Dec 13, 2022):

This was fixed by #14282. Thank you again for your report! It was quite helpful during later testing.

@lhecker commented on GitHub (Dec 13, 2022): This was fixed by #14282. Thank you again for your report! It was quite helpful during later testing.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#18023