Esempio n. 1
0
        private static unsafe void StartProcess(string[] args, NativeJob job)
        {
            using (var atts = new ProcThreadAttributeList(1))
                using (var shellProc = GetShellProcess()) {
                    IntPtr shellHandle = shellProc.Handle.DangerousGetHandle();

                    atts.AddAttribute <IntPtr>(ProcThreadAttribute.ParentProcess, &shellHandle);

                    using (NativeProcess natProcess = NativeProcess.CreateProcess(args[0], null, CreateProcessFlags.None, StartupInfoFlags.None, atts, null, out _)) {
                        job.AttachProcess(natProcess);
                    }
                }
        }
Esempio n. 2
0
        static unsafe void Main(string[] args)
        {
            using (NativeJob job = NativeJob.Create()) {
                var extended = job.ExtendedLimitInformation;
                extended.LimitFlags          = LimitFlags.JobTime | LimitFlags.JobMemory;
                extended.PerJobUserTimeLimit = new TimeSpan(0, 5, 0);
                extended.JobMemoryLimit      = 1024 * 1024 * 100;
                job.ExtendedLimitInformation = extended;

                if (args.Length >= 1)
                {
                    StartProcess(args, job);
                }
            }
        }