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


           Summary: Process.Start inherits environment even when
                    EnvironmentVariables.Clear has been used
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.4.x
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: System
        AssignedTo: [email protected]
        ReportedBy: [email protected]
         QAContact: [email protected]
          Found By: ---


User-Agent:       Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1b2)
Gecko/20081212 Minefield/3.1b2

If you create a ProcessStartInfo and call EnvironmentVariables.Clear,
subsequent Process.Start call will inherit the current environment instead of
clearing it.

Reproducible: Always

Steps to Reproduce:
Compile and run following test code, after setting environment variable "foo"
to some value. (Similar works for linux with sh -c echo $foo)

using System;
using System.Diagnostics;

class MainClass
{
    static void Main()
    {
        string Cmd = "cmd";
        string Args = "/c echo %foo%";

        ProcessStartInfo Info = new ProcessStartInfo();
        Info.FileName = Cmd;
        Info.UseShellExecute = false;
        Info.Arguments = Args;
        Process.Start(Info);
        Info.EnvironmentVariables.Clear();
        Process.Start(Info);
    }
}

Actual Results:  
C:\temp>set foo=bar

C:\temp>MainClass.exe
bar
%foo%

C:\temp>mono MainClass.exe
bar
bar


Expected Results:  
bar
%foo%


Problem seems to be in mcs/class/System/System.Diagnostics/Process.cs, method
Start_noshell. It uses the HaveEnvVars property of the ProcessStartInfo, which
returns false for an empty but existing set.

-- 
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.
_______________________________________________
mono-bugs maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-bugs

Reply via email to