[1.15+] timeout in a batch script instantly exits a defterm window #19019

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

Originally created by @zadjii-msft on GitHub (Dec 6, 2022).

Oh god this is so much worse in 1.15. It doesn't timeout at all, it instantly exits!

echo foo
@rem set /p id=Enter ID: 
timeout /t 10
echo bar
exit 1234

image

Originally posted by @zadjii-msft in https://github.com/microsoft/terminal/issues/12951#issuecomment-1338357561

Originally created by @zadjii-msft on GitHub (Dec 6, 2022). Oh god this is so much worse in 1.15. It doesn't timeout at all, it instantly exits! ```cmd echo foo @rem set /p id=Enter ID: timeout /t 10 echo bar exit 1234 ``` ![image](https://user-images.githubusercontent.com/18356694/205757385-aa1719f2-cffd-41ee-8d9b-a8ec19051610.png) _Originally posted by @zadjii-msft in https://github.com/microsoft/terminal/issues/12951#issuecomment-1338357561_
claunia added the Issue-BugNeeds-Tag-FixProduct-TerminalPriority-1Area-DefApp labels 2026-01-31 06:31:21 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Dec 6, 2022):

OH oh oh I bet this has to do with focus events. That's my guess - timeout will bail on input. Like, any input? That I'm not sure about. But I bet the regression between 1.12 when this was filed, and now (1.15/16/17) is the focus event stuff, and I bet eveything is immediately getting a focus event in the input queue right off the bat.

I'll need to go inspect timeout's source to confirm. That's my hypothesis.

Notably, this doesn't repro the same if you actually "restart" the batch script, until you press a key:
image

I noticed this when I restored the Terminal from being quit, and this defterm window came back (presumably, without the focus event). This might be related to #13514

Okay, my hypothesis was wrong. Looks like timeout does filter FOCUS events out... even if it does have some other horrifying code in it.

@zadjii-msft commented on GitHub (Dec 6, 2022): ~OH oh oh I bet this has to do with focus events. That's my guess - `timeout` will bail on input. Like, any input? That I'm not sure about. But I bet the regression between 1.12 when this was filed, and now (1.15/16/17) is the focus event stuff, and I bet eveything is immediately getting a focus event in the input queue right off the bat.~ I'll need to go inspect `timeout`'s source to confirm. That's my hypothesis. Notably, this doesn't repro the same if you actually "restart" the batch script, until you press a key: ![image](https://user-images.githubusercontent.com/18356694/205942092-7f79e221-790c-47cc-8ee5-9df8cf558c8a.png) I noticed this when I restored the Terminal from being quit, and this defterm window came back ~(presumably, without the focus event)~. This might be related to #13514 Okay, my hypothesis was wrong. Looks like `timeout` does filter FOCUS events out... even if it does have some other horrifying code in it.
Author
Owner

@zadjii-msft commented on GitHub (Sep 20, 2023):

Uh, this looks fixed. At least in 1.19.whatever.this.selfhost.build.is

@zadjii-msft commented on GitHub (Sep 20, 2023): Uh, this looks fixed. At least in 1.19.whatever.this.selfhost.build.is
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#19019