Bug 57584 - SIGINT not handled when stdout is redirected
Summary: SIGINT not handled when stdout is redirected
Alias: None
Product: Runtime
Classification: Mono
Component: io-layer ()
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Ludovic Henry
Depends on:
Reported: 2017-06-19 00:14 UTC by Shravan Rajinikanth
Modified: 2017-10-03 20:31 UTC (History)
4 users (show)

Is this bug a regression?: ---
Last known good build:

The process that receives the SIGINT (507 bytes, text/plain)
2017-06-29 03:07 UTC, Shravan Rajinikanth
The program that sends the SIGINT (1.34 KB, text/plain)
2017-06-29 03:08 UTC, Shravan Rajinikanth
Parent process (1.04 KB, text/plain)
2017-06-29 15:46 UTC, Ludovic Henry
Child process (465 bytes, text/plain)
2017-06-29 15:46 UTC, Ludovic Henry

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report for Bug 57584 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description Shravan Rajinikanth 2017-06-19 00:14:40 UTC
I use Mono 5.0.1 on Ubuntu 16.04.2 LTS.

I have a program that runs a sub process and monitors its activity. The child process is configured to handle Console.CancelKeyPress. An SSCCE of the main program is

ProcessStartInfo psi = new ProcessStartInfo
    WorkingDirectory = "/home/user/TestLab",
    FileName = "mono",
    Arguments = "TestLab.exe",
    UseShellExecute = false,
    //RedirectStandardOutput = true

_proc = new Process();
_proc.StartInfo = psi;
_proc.EnableRaisingEvents = true;
_proc.Exited += (sender, eventArgs) => Console.WriteLine($"Process exited with code {_proc.ExitCode}");
//_proc.OutputDataReceived += (sender, eventArgs) => { };

After running this program, I send a SIGINT using "kill -SIGINT <pid>" to the child process. It exits correctly and prints "Process exited with code 0". However, when the lines above are un-commented, the child process exits with code 130, which does not allow it to exit gracefully.
Comment 1 Shravan Rajinikanth 2017-06-19 02:40:01 UTC
I ran some more tests which confirm that this is not the behavior in .NET Core either.
Comment 2 Ludovic Henry 2017-06-28 19:32:02 UTC
Hello Shravan Rajinikanth, could you please provide a source file for the parent, as well as a source file for the child. I tried to reproduce and can't get the same results as you. Thank you.
Comment 3 Shravan Rajinikanth 2017-06-29 03:07:49 UTC
Created attachment 23190 [details]
The process that receives the SIGINT
Comment 4 Shravan Rajinikanth 2017-06-29 03:08:14 UTC
Created attachment 23191 [details]
The program that sends the SIGINT
Comment 5 Shravan Rajinikanth 2017-06-29 03:12:04 UTC
Hello Ludovic Henry, please use CTRL+C to send the SIGINT and let me know if you have any other issues.

Comment 6 Ludovic Henry 2017-06-29 15:46:10 UTC
Created attachment 23219 [details]
Parent process
Comment 7 Ludovic Henry 2017-06-29 15:46:28 UTC
Created attachment 23220 [details]
Child process
Comment 8 Ludovic Henry 2017-06-29 15:47:13 UTC

I can reproduce with the program attached. I will look into it ASAP.

Thank you very much for your quick answer,

Comment 9 Shravan Rajinikanth 2017-10-03 20:31:36 UTC
Do you have an update on this issue?