This repository was archived by the owner on Jan 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Process: avoid performing operations on a different process with recycled pid #28404
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
738d1c0
Process: avoid performing operations on a different process with recy…
tmds 94cf9a9
ThrowIfExited: don't create ProcessWaitState(Holder) if we are not re…
tmds badc2f3
Handle non-child pid recycling
tmds 909b124
ProcessWaitState: update overview comment to reflect current implemen…
tmds 836e3cf
Merge remote-tracking branch 'upstream/master' into check_exited
tmds 48dbcec
Update TestProcessRecycledPid
tmds ea97178
Add comment to ThrowIfExited
tmds dab279d
Remove CultureInfo.CurrentCulture from _processId.ToString
tmds File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -302,7 +302,7 @@ public ProcessModuleCollection Modules | |
| { | ||
| if (_modules == null) | ||
| { | ||
| EnsureState(State.HaveId | State.IsLocal); | ||
| EnsureState(State.HaveNonExitedId | State.IsLocal); | ||
| _modules = ProcessManager.GetModules(_processId); | ||
| } | ||
| return _modules; | ||
|
|
@@ -907,6 +907,10 @@ public void Close() | |
| } | ||
| } | ||
|
|
||
| // Checks if the process hasn't exited on Unix systems. | ||
| // This is used to detect recycled child PIDs. | ||
| partial void ThrowIfExited(bool refresh); | ||
|
|
||
| /// <devdoc> | ||
| /// Helper method for checking preconditions when accessing properties. | ||
| /// </devdoc> | ||
|
|
@@ -931,6 +935,10 @@ private void EnsureState(State state) | |
| throw new InvalidOperationException(SR.ProcessIdRequired); | ||
| } | ||
| } | ||
| if ((state & State.HaveNonExitedId) == State.HaveNonExitedId) | ||
| { | ||
| ThrowIfExited(refresh: false); | ||
| } | ||
| } | ||
|
|
||
| if ((state & State.IsLocal) != (State)0 && _isRemoteMachine) | ||
|
|
@@ -942,7 +950,10 @@ private void EnsureState(State state) | |
| { | ||
| if (_processInfo == null) | ||
| { | ||
| if ((state & State.HaveId) == (State)0) EnsureState(State.HaveId); | ||
| if ((state & State.HaveNonExitedId) != State.HaveNonExitedId) | ||
| { | ||
| EnsureState(State.HaveNonExitedId); | ||
| } | ||
| _processInfo = ProcessManager.GetProcessInfo(_processId, _machineName); | ||
| if (_processInfo == null) | ||
| { | ||
|
|
@@ -1514,6 +1525,7 @@ private enum State | |
| { | ||
| HaveId = 0x1, | ||
| IsLocal = 0x2, | ||
| HaveNonExitedId = HaveId | 0x4, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was nice of Nt to leave a gap here :) |
||
| HaveProcessInfo = 0x8, | ||
| Exited = 0x10, | ||
| Associated = 0x20, | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe combine the above into:
?