Пример #1
0
        protected static void CleanupApp(AppProcess app)
        {
            if (app == null)
            {
                throw new ArgumentException("App cannot be null", nameof(app));
            }

            int processId = app.ProcessId;

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                ProcessUtility.KillProcessWindows(processId, _fileSystem, out string _, out string _);
            }
            else
            {
                var children = new HashSet <int>();
                ProcessUtility.GetAllChildIdsUnix(processId, children, _fileSystem);
                foreach (var childId in children)
                {
                    ProcessUtility.KillProcessUnix(childId, _fileSystem, out string _, out string _);
                }

                ProcessUtility.KillProcessUnix(processId, _fileSystem, out string _, out string _);
            }
        }
Пример #2
0
        public void KillProcessTree(AppProcess process, CommandOptions options, TimeSpan timeout)
        {
            if (process == null)
            {
                throw new ArgumentNullException(nameof(process));
            }

            string stdout;
            string stderr;

            if (_isWindows)
            {
                ProcessUtility.KillProcessWindows(process.ProcessId, _fileSystem, out stdout, out stderr);
                LogOutputs(stdout, stderr, options);
            }
            else
            {
                var children = new HashSet <int>();
                ProcessUtility.GetAllChildIdsUnix(process.ProcessId, children, _fileSystem);
                foreach (var childId in children)
                {
                    ProcessUtility.KillProcessUnix(childId, _fileSystem, out stdout, out stderr);
                    LogOutputs(stdout, stderr, options);
                }

                ProcessUtility.KillProcessUnix(process.ProcessId, _fileSystem, out stdout, out stderr);
                LogOutputs(stdout, stderr, options);
            }

            process.Kill(timeout, _console);
        }