Skip to content

Implement 5s timeout for ConPTY handoff embedding.#20051

Open
Kuldeep2822k wants to merge 1 commit intomicrosoft:mainfrom
Kuldeep2822k:handoff-timeout-timer
Open

Implement 5s timeout for ConPTY handoff embedding.#20051
Kuldeep2822k wants to merge 1 commit intomicrosoft:mainfrom
Kuldeep2822k:handoff-timeout-timer

Conversation

@Kuldeep2822k
Copy link
Copy Markdown

Add a timer in WindowEmperor to automatically exit after 5 seconds if no windows are created during a ConPTY handoff. The timer is cancelled as soon as a new window is created. This prevents the process from staying alive indefinitely if a handoff fails or is never received.

Summary of the Pull Request

I've implemented a 5-second timeout for the ConPTY handoff embedding in the Windows Terminal.

  1. Added a SafeDispatcherTimer _handoffTimeoutTimer; member to the WindowEmperor class.
  2. In HandleCommandlineArgs, when the application is launched with the -Embedding flag (ConPTY handoff), the timer is started with a 5-second interval.
  3. If the timer ticks (indicating no window was created within 5 seconds), it calls _postQuitMessageIfNeeded() to attempt an application exit.
  4. In CreateNewWindow, the timer is explicitly stopped to ensure that the application doesn't exit if a window is successfully created.

The implementation follows the existing codebase patterns using SafeDispatcherTimer and _postQuitMessageIfNeeded

References and Relevant Issues

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

PR Checklist

  • Closes #xxx
  • Tests added/passed
  • Documentation updated
    • If checked, please file a pull request on our docs repo and link it here: #xxx
  • Schema updated (if necessary)

Add a timer in WindowEmperor to automatically exit after 5 seconds if
no windows are created during a ConPTY handoff. The timer is cancelled
as soon as a new window is created. This prevents the process from
staying alive indefinitely if a handoff fails or is never received.
@Kuldeep2822k
Copy link
Copy Markdown
Author

@Kuldeep2822k please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@microsoft-github-policy-service agree

@lhecker
Copy link
Copy Markdown
Member

lhecker commented Apr 2, 2026

How did you test this?

@Kuldeep2822k
Copy link
Copy Markdown
Author

How did you test this?

I tested this by launching wt.exe -Embedding without sending a handoff signal. The process (PID 18960) exited automatically after ~5 seconds, confirming the SafeDispatcherTimer fires and calls _postQuitMessageIfNeeded() correctly. Without this fix, the process would remain alive indefinitely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants