Bug 42983 - process.Exited event is called before process is exited
Summary: process.Exited event is called before process is exited
Alias: None
Product: Runtime
Classification: Mono
Component: General ()
Version: 4.7.X
Hardware: PC Mac OS
: High blocker
Target Milestone: ---
Assignee: Ludovic Henry
Depends on:
Reported: 2016-08-02 09:36 UTC by David Karlaš
Modified: 2016-08-04 13:03 UTC (History)
3 users (show)

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

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 on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description David Karlaš 2016-08-02 09:36:18 UTC
Example code:
using System;
using System.Diagnostics;
using System.Threading;

class Program
    public static void Main(string[] args)
        var process = Process.Start("ping", "");
        process.EnableRaisingEvents = true;
        process.Exited += (sender, e) => {

PING ( 56 data bytes
64 bytes from icmp_seq=0 ttl=54 time=39.794 ms
64 bytes from icmp_seq=1 ttl=54 time=39.534 ms
64 bytes from icmp_seq=2 ttl=54 time=39.888 ms
64 bytes from icmp_seq=3 ttl=54 time=39.465 ms

Which is wrong because "Exited!!" shouldn't be called until `ping` process is terminated...
Comment 1 Ludovic Henry 2016-08-04 12:54:13 UTC
This is fixed with https://github.com/mono/mono/pull/3355
Comment 2 Ludovic Henry 2016-08-04 12:54:29 UTC
Should it be backported to some cycle8 branches?
Comment 3 David Karlaš 2016-08-04 12:56:18 UTC
I think this regression is not present in C8, but if it's present in C8, yes it needs backporting imo.
Comment 4 Ludovic Henry 2016-08-04 13:02:35 UTC
The commit that introduced the regression doesn't seem to be on mono-4.6.0-branch, so no need to backport anything
Comment 5 David Karlaš 2016-08-04 13:03:36 UTC
Awesome! Tnx for you quick fixing.