Last active
December 6, 2017 08:58
-
-
Save lpenguin/a7db1e10eecd28e3608f8039c9437c83 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mcs EnvPrinter.cs -out:EnvPrinter.exe | |
mcs Runner.cs -out:Runner.exe | |
export MONO_GC_PARAMS=max-heap-size=1k | |
mono Runner.exe mono EnvPrinter.exe MONO_GC_PARAMS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
namespace envvartest | |
{ | |
internal static class EnvPrinter | |
{ | |
public static void Main(string[] args) | |
{ | |
var varName = args[0]; | |
var res = Environment.GetEnvironmentVariable(varName); | |
Console.WriteLine($"{varName} = {res}"); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Diagnostics; | |
using System.Linq; | |
namespace runner | |
{ | |
internal class Program | |
{ | |
public static void Main(string[] args) | |
{ | |
var cmd = args[0]; | |
string cmdArgs = string.Join(" ", args.Skip(1)); | |
ProcessStartInfo psi = new ProcessStartInfo(cmd, cmdArgs); | |
psi.WindowStyle = ProcessWindowStyle.Hidden; | |
var process = new Process {StartInfo = psi}; | |
psi.CreateNoWindow = true; | |
psi.UseShellExecute = false; | |
process.Start(); | |
int processid = process.Id; | |
process.WaitForExit(); | |
int exitcode = process.ExitCode; | |
process.Close(); | |
if (exitcode != 0) { | |
throw new Exception("Exception during execution of external process: " + processid); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That basically means that export parameters for all internal
Process
are inherited.