diff --git a/SampleCommand/PlatformCompatibilityTests.cs b/SampleCommand/PlatformCompatibilityTests.cs index 6b26ad0..335ae8a 100644 --- a/SampleCommand/PlatformCompatibilityTests.cs +++ b/SampleCommand/PlatformCompatibilityTests.cs @@ -72,11 +72,18 @@ public static void TestBadProcessFile() public static void TestAttaching() { - var processCommand = Command.Run("SampleCommand", new[] { "sleep", "10000" }); - var processId = processCommand.ProcessId; - if (!Command.TryAttachToProcess(processId, out _)) + var processCommand = Command.Run(SampleCommandPath, new[] { "sleep", "10000" }); + try { - throw new InvalidOperationException("Wasn't able to attach to the running process."); + var processId = processCommand.ProcessId; + if (!Command.TryAttachToProcess(processId, out _)) + { + throw new InvalidOperationException("Wasn't able to attach to the running process."); + } + } + finally + { + processCommand.Kill(); } }