From 7cbc169ba0d50f6d6adf8159ff8cfd02b30c6680 Mon Sep 17 00:00:00 2001 From: James Truher Date: Fri, 3 Sep 2021 13:30:34 -0700 Subject: [PATCH 1/2] The signal enum in the native library should match the managed code. --- src/libraries/Native/Unix/System.Native/pal_signal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/Native/Unix/System.Native/pal_signal.h b/src/libraries/Native/Unix/System.Native/pal_signal.h index 146fdabbfceb14..c3c21009dc836c 100644 --- a/src/libraries/Native/Unix/System.Native/pal_signal.h +++ b/src/libraries/Native/Unix/System.Native/pal_signal.h @@ -40,8 +40,8 @@ typedef enum PosixSignalSIGQUIT = -3, PosixSignalSIGTERM = -4, PosixSignalSIGCHLD = -5, - PosixSignalSIGWINCH = -6, - PosixSignalSIGCONT = -7, + PosixSignalSIGCONT = -6, + PosixSignalSIGWINCH = -7, PosixSignalSIGTTIN = -8, PosixSignalSIGTTOU = -9, PosixSignalSIGTSTP = -10 From 0d8b1c10094b5b9b01eb4723087fcf52e7883de0 Mon Sep 17 00:00:00 2001 From: Tom Deseyn Date: Tue, 7 Sep 2021 16:06:32 +0200 Subject: [PATCH 2/2] PosixSignalRegistrationTests.Unix: validate signal pal mapping (#58711) * PosixSignalRegistrationTests.Unix: validate signal pal mapping * Use InvariantCulture for pid ToString * Invoke kill through shell. * Remove InvariantCulture --- .../PosixSignalRegistrationTests.Unix.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/PosixSignalRegistrationTests.Unix.cs b/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/PosixSignalRegistrationTests.Unix.cs index 4b0c9fc01dea3a..f844b4d160a884 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/PosixSignalRegistrationTests.Unix.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/PosixSignalRegistrationTests.Unix.cs @@ -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; @@ -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();