Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
PosixSignalRegistrationTests.Unix: validate signal pal mapping (#58711)
* PosixSignalRegistrationTests.Unix: validate signal pal mapping

* Use InvariantCulture for pid ToString

* Invoke kill through shell.

* Remove InvariantCulture
  • Loading branch information
tmds authored and stephentoub committed Sep 7, 2021
commit 0d8b1c10094b5b9b01eb4723087fcf52e7883de0
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.

using Xunit;
using System.Diagnostics;
using System.Globalization;
using System.Threading;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
Expand Down Expand Up @@ -57,7 +59,16 @@ public void SignalHandlerCalledForKnownSignals(PosixSignal s)
semaphore.Release();
});

kill(signal);
// Use 'kill' command with signal name to validate the signal pal mapping.
string sigArg = signalStr.StartsWith("SIG") ? signalStr.Substring(3) : signalStr;
using var process = Process.Start(new ProcessStartInfo
{
FileName = "/bin/sh", // Use a shell because not all platforms include a 'kill' executable.
ArgumentList = { "-c", $"kill -s {sigArg} {Environment.ProcessId.ToString()}" }
});
process.WaitForExit();
Assert.Equal(0, process.ExitCode);

bool entered = semaphore.Wait(SuccessTimeout);
Assert.True(entered);
}, s.ToString()).Dispose();
Expand Down