Skip to content

Instantly share code, notes, and snippets.

@lpenguin

lpenguin/EnvPrinter.cs

Last active Dec 6, 2017
Embed
What would you like to do?
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

This comment has been minimized.

Copy link

@pgsin 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