[Mono-bugs] [Bug 499330] New: Registered System.Diagnostics.Process.Exited event is called immediately

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed Apr 29 12:15:23 EDT 2009


http://bugzilla.novell.com/show_bug.cgi?id=499330


           Summary: Registered System.Diagnostics.Process.Exited event is
                    called immediately
    Classification: Mono
           Product: Mono: Class Libraries
           Version: SVN
          Platform: x86-64
        OS/Version: RHEL 4
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: System
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: phamorsky at yahoo.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


User-Agent:       Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; WOW64;
SV1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648)

Called System.Diagnostics.Process.GetProcessById() and registered a
Process.Exited event.  The event is called immediately even though the process
being monitored has not exited.  The sample code works on Mono Winx64 but does
not work for Mono Linux x86_64.  I did not try x86.

/*** SAMPLE CODE ***/
using System;
using System.Collections.Generic;
using System.Text;
namespace GetProcessByIdTest
{
    class Program
    {
        static bool process_exited = false;
        static int pid = -1;
        static void ProcessExited(object sender, EventArgs e)
        {
            Console.WriteLine("The process we were watching terminated");
            process_exited = true;
        }
        public static void Main(String[] args)
        {
            Console.WriteLine("Enter process ID to watch =");
            string str = Console.ReadLine();
            int pid = int.Parse(str);
            Console.WriteLine("Watching process id " + pid);

            System.Diagnostics.Process process =
System.Diagnostics.Process.GetProcessById(pid);
            process.EnableRaisingEvents = true;
            process.Exited += new EventHandler(ProcessExited);
            // wait until the process exits
            while (!process_exited)
                continue;
            Console.WriteLine("...Done");
        }
    }
}

Reproducible: Always

Steps to Reproduce:
1.compile sample code
2.start some application on linux, gedit
3.start the sample code
4.enter the process id of the gedit process
Actual Results:  
before the gedit app. is closed, the sample program ends after printing ...

"The process we were watching terminated
..Done"

Expected Results:  
the sample program should print nothing after the pid to watch is entered. 
once the gedit app. is closed, then the sample program should print ...
"The process we were watching terminated
..Done"

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list