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 (show other bugs)
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)

See Also:
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

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?


Note You need to log in before you can comment on or make changes to this bug.