Skip to content

Instantly share code, notes, and snippets.

@lpenguin
Last active December 6, 2017 08:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lpenguin/a7db1e10eecd28e3608f8039c9437c83 to your computer and use it in GitHub Desktop.
Save lpenguin/a7db1e10eecd28e3608f8039c9437c83 to your computer and use it in GitHub Desktop.
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
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}");
}
}
}
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);
}
}
}
}
@pgsin
Copy link

pgsin commented Dec 5, 2017

Warning: In environment variable `MONO_GC_PARAMS': `max-heap-size` size must be a multiple of 4096. - Rounding up.
Warning: In environment variable `MONO_GC_PARAMS': `max-heap-size` must be at least 4 times as large as `nursery size`. - Setting to minimum.
Warning: In environment variable `MONO_GC_PARAMS': `max-heap-size` size must be a multiple of 4096. - Rounding up.
Warning: In environment variable `MONO_GC_PARAMS': `max-heap-size` must be at least 4 times as large as `nursery size`. - Setting to minimum.
MONO_GC_PARAMS = max-heap-size=1k

That basically means that export parameters for all internal Process are inherited.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment