public void CanSendSignal()
{
var si = new ChildProcessStartInfo(TestUtil.TestChildNativePath, "ReportSignal")
{
StdInputRedirection = InputRedirection.InputPipe,
StdOutputRedirection = OutputRedirection.OutputPipe,
};
using var sut = ChildProcess.Start(si);
Assert.True(sut.CanSignal);
Assert.Equal('R', sut.StandardOutput.ReadByte());
sut.SignalInterrupt();
Assert.Equal('I', sut.StandardOutput.ReadByte());
sut.SignalInterrupt();
Assert.Equal('I', sut.StandardOutput.ReadByte());
if (!HasWorkaroundForWindows1809)
{
// NOTE: On Windows, a console app cannot cancel CTRL_CLOSE_EVENT (generated when the attached pseudo console is closed).
// It will be killed after the 5s-timeout elapses. Once we call SignalTermination, we must treat the app as already terminated.
// https://docs.microsoft.com/en-us/windows/console/handlerroutine#timeouts
sut.SignalTermination();
Assert.Equal('T', sut.StandardOutput.ReadByte());
}
sut.Kill();
sut.WaitForExit();
Assert.NotEqual(0, sut.ExitCode);
}