Skip to content

Commit c5b7d59

Browse files
Copilotjkotas
andauthored
Replace local ResumeThread P/Invoke in ProcessHandlesTests with shared Interop.Kernel32.ResumeThread
Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/e8bb36bc-5c71-4723-a32c-17e87d762370 Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
1 parent 8beb026 commit c5b7d59

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/libraries/System.Diagnostics.Process/tests/ProcessHandlesTests.Windows.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ private unsafe int RunWithInvalidHandles(ProcessStartInfo startInfo)
157157
// As soon as SafeProcessHandle.WaitForExit* are implemented (#126293), we can use them instead.
158158
using Process process = Process.GetProcessById(processInfo.dwProcessId);
159159

160-
if (ResumeThread(processInfo.hThread) == -1)
160+
if (Interop.Kernel32.ResumeThread(processInfo.hThread) == 0xFFFFFFFF)
161161
{
162162
throw new Win32Exception();
163163
}
@@ -183,9 +183,6 @@ private unsafe int RunWithInvalidHandles(ProcessStartInfo startInfo)
183183
}
184184
}
185185

186-
[LibraryImport(Interop.Libraries.Kernel32)]
187-
private static partial int ResumeThread(nint hThread);
188-
189186
private static unsafe string GetSafeFileHandleId(SafeFileHandle handle)
190187
{
191188
const int MaxPath = 32_767;

src/libraries/System.Diagnostics.Process/tests/System.Diagnostics.Process.Tests.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@
7171
Link="Common\Interop\Windows\Kernel32\Interop.SetConsoleCtrlHandler.cs" />
7272
<Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.GetFinalPathNameByHandle.cs"
7373
Link="Common\Interop\Windows\Kernel32\Interop.GetFinalPathNameByHandle.cs" />
74+
<Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.ResumeThread.cs"
75+
Link="Common\Interop\Windows\Kernel32\Interop.ResumeThread.cs" />
7476
<!-- Helpers -->
7577
<Compile Include="$(CommonTestPath)TestUtilities\System\WindowsTestFileShare.cs" Link="Common\TestUtilities\System\WindowsTestFileShare.cs" />
7678
</ItemGroup>

0 commit comments

Comments
 (0)