Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up child process exits on Windows #3817

Merged
merged 4 commits into from
Aug 4, 2021

Conversation

chalcolith
Copy link
Member

In Windows we are closing the process handle when the process successfully exits. However, the wait timer in ProcessMonitor repeatedly calls wait on the child, even after it's exited.

This change makes ProcessMonitor and _ProcessWindows cache final values for the process exit status, so repeated calls to wait on the child will not be referencing an invalid handle.

This also fixes a combinatorial explosion of timers in ProcessMonitor._wait_for_child().

In Windows we are closing the process handle when the process successfully exits. However, the wait timer in `ProcessMonitor` repeatedly calls wait on the child, even after it's exited.

This change makes `ProcessMonitor` and `_ProcessWindows` cache final values for the process exit status, so repeated calls to wait on the child will not be referencing an invalid handle.

This also fixes a combinatorial explosion of timers in `ProcessMonitor._wait_for_child()`.
@chalcolith chalcolith added the changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge label Aug 3, 2021
@ponylang-main
Copy link
Contributor

Hi @kulibali,

The changelog - fixed label was added to this pull request; all PRs with a changelog label need to have release notes included as part of the PR. If you haven't added release notes already, please do.

Release notes are added by creating a uniquely named file in the .release-notes directory. We suggest you call the file 3817.md to match the number of this pull request.

The basic format of the release notes (using markdown) should be:

## Title

End user description of changes, why it's important,
problems it solves etc.

If a breaking change, make sure to include 1 or more
examples what code would look like prior to this change
and how to update it to work after this change.

Thanks.

Copy link
Contributor

@mfelsche mfelsche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing up my mess @kulibali

LGTM 💯

Comment on lines 348 to +350
let hProcess: USize
let processError: (ProcessError | None)
var finalWaitResult: (_WaitResult | None) = None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

per the style guide, we use snake case for fields.

I'll open an issue for that.

https://github.com/ponylang/ponyc/blob/main/STYLE_GUIDE.md#naming

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

opened: #3818

@SeanTAllen
Copy link
Member

@kulibali is there any way to test this in an automated fashion?

if not, i feel like, as part of the commit comment for this, there should be a note for future reference on how to manually test.

@chalcolith
Copy link
Member Author

I'll take a look at adding a test.

@SeanTAllen SeanTAllen added the do not merge This PR should not be merged at this time label Aug 4, 2021
@chalcolith chalcolith removed the do not merge This PR should not be merged at this time label Aug 4, 2021
@chalcolith chalcolith requested a review from a team August 4, 2021 15:03
@SeanTAllen SeanTAllen merged commit 1e5abdf into main Aug 4, 2021
@SeanTAllen SeanTAllen deleted the kulibali/windows_process_fixes branch August 4, 2021 19:47
github-actions bot pushed a commit that referenced this pull request Aug 4, 2021
github-actions bot pushed a commit that referenced this pull request Aug 4, 2021
ergl added a commit that referenced this pull request Sep 2, 2021
This test was added on PR #3817, which was missed by PR #3819
since it wasn't rebased.
SeanTAllen pushed a commit that referenced this pull request Sep 2, 2021
This test was added on PR #3817, which was missed by PR #3819
since it wasn't rebased.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants