Terminate() public method

public Terminate ( uint exitCode ) : void
exitCode uint
return void
Beispiel #1
0
        private string GetProjectFile(string path)
        {
            var projectFile = String.Empty;
            var attr        = File.GetAttributes(path);

            if ((attr & FileAttributes.Directory) == FileAttributes.Directory)
            {
                var projectFiles = Directory.GetFiles(path, "*.csproj");

                if (!projectFiles.Any())
                {
                    Process.Terminate("Could not found a project file in the specified directory.");
                }

                projectFile = projectFiles.First();
            }
            else
            {
                var extension = Path.GetExtension(path);

                if (!extension.Equals(".csproj"))
                {
                    Process.Terminate("You must provide a proper project file.");
                }

                projectFile = path;
            }

            return(projectFile);
        }
 /// <summary>
 /// Terminate the process
 /// </summary>
 /// <param name="exitcode">Exit code for termination</param>
 public void Terminate(NtStatus exitcode)
 {
     if (Process != null)
     {
         Process.Terminate(exitcode);
     }
 }
        public static async Task ClassCleanup()
        {
            // close first to avoid a case where Silo hangs, I stop the test and the proxy process keeps running
            _proxyProcess.Terminate();

            await _cluster.Shutdown();
        }
Beispiel #4
0
        public static void ClassCleanup()
        {
            // close first to avoid a case where Silo hangs, I stop the test and the proxy process keeps running
            _proxyProcess?.Terminate();

            _cluster.Dispose();
        }
Beispiel #5
0
        public static async Task RunAsync(ExportOptions options)
        {
            if (!Directory.Exists(options.ProjectPath))
            {
                Process.Terminate("The specified directory is not found.");
            }

            var packageService  = new PackageService();
            var packageInfoList = await packageService.GetPackageInfoList(options.ProjectPath);

            var outputDir = String.IsNullOrEmpty(options.OutputPath) ?
                            Directory.GetCurrentDirectory() :
                            options.OutputPath;

            var fileName = Path.GetFileName(options.ProjectPath) + "_packages";

            if (options.Json)
            {
                var jsonOptions = new JsonSerializerOptions()
                {
                    WriteIndented = true
                };

                using FileStream createStream = File.Create($"{outputDir}/{fileName}.json");
                await JsonSerializer.SerializeAsync(createStream, packageInfoList, jsonOptions);
            }
            else if (options.Csv)
            {
                using (var writer = new StreamWriter($"{outputDir}/{fileName}.csv"))
                    using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
                    {
                        csv.WriteRecords(packageInfoList);
                    }
            }
        }
Beispiel #6
0
        public static async Task RunAsync(ListOptions options)
        {
            var projectPath = options.ProjectPath;

            if (!Directory.Exists(projectPath) && !File.Exists(projectPath))
            {
                Process.Terminate("The specified directory or file is not found.");
            }

            var packageService  = new PackageService();
            var packageInfoList = await packageService.GetPackageInfoList(projectPath);

            var table = new ConsoleTable("PACKAGE", "AUTHOR", "VERSION", "LATEST", "SIZE", "PUBLISHED", "LAST UPDATE");

            foreach (var info in packageInfoList)
            {
                table.AddRow(info.Name,
                             info.Author,
                             info.Version,
                             info.LatestVersion,
                             info.Size,
                             info.PublishDate,
                             info.LastUpdate);
            }

            Console.WriteLine();
            table.Write(Format.Minimal);
        }
Beispiel #7
0
        public async Task Start(Connection connection, ElevationRequest request)
        {
            Native.ConsoleApi.SetConsoleCtrlHandler(ConsoleHelper.IgnoreConsoleCancelKeyPress, true);

            _connection = connection;

            try
            {
                process = ProcessFactory.StartRedirected(request.FileName, request.Arguments, request.StartFolder);

                Logger.Instance.Log($"Process ({process.Id}) started: {request.FileName} {request.Arguments}", LogLevel.Debug);

                var t1 = process.StandardOutput.ConsumeOutput(WriteToPipe);
                var t2 = process.StandardError.ConsumeOutput(WriteToErrorPipe);
                var t3 = new StreamReader(connection.DataStream, Settings.Encoding).ConsumeOutput((s) => WriteToProcessStdIn(s, process));
                var t4 = new StreamReader(connection.ControlStream, Settings.Encoding).ConsumeOutput((s) => HandleControl(s, process));

                if (Settings.SecurityEnforceUacIsolation)
                {
                    process.StandardInput.Close();
                }

                WaitHandle.WaitAny(new WaitHandle[] { process.GetProcessWaitHandle(), connection.DisconnectedWaitHandle });

                if (process.HasExited && connection.IsAlive)
                {
                    // we need to ensure that all process output is read.
                    while (ShouldWait(process.StandardError) || ShouldWait(process.StandardOutput))
                    {
                        await Task.Delay(1).ConfigureAwait(false);
                    }

                    await Task.WhenAll(t1, t2).ConfigureAwait(false);

                    await connection.ControlStream.WriteAsync($"{Constants.TOKEN_EXITCODE}{process.ExitCode}{Constants.TOKEN_EXITCODE}").ConfigureAwait(false);
                }

                await connection.FlushAndCloseAll().ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                Logger.Instance.Log(ex.ToString(), LogLevel.Error);

                await connection.ControlStream.WriteAsync($"{Constants.TOKEN_ERROR}Server Error: {ex.ToString()}\r\n{Constants.TOKEN_ERROR}").ConfigureAwait(false);

                await connection.FlushAndCloseAll().ConfigureAwait(false);
            }
            finally
            {
                Native.ConsoleApi.SetConsoleCtrlHandler(HandleConsoleCancelKeyPress, false);
                if (process != null && !process.HasExited)
                {
                    process?.Terminate();
                }
                process?.Dispose();
            }
        }
 /// <summary>
 /// Dispose the process.
 /// </summary>
 public void Dispose()
 {
     if (TerminateOnDispose)
     {
         Process?.Terminate(NtStatus.STATUS_PROCESS_IS_TERMINATING, false);
     }
     Process?.Dispose();
     Thread?.Dispose();
 }
Beispiel #9
0
        // Terminates the program.
        public int Terminate()
        {
            Debug.WriteLine("NodeEngine Terminate");
            // Because we implement IDebugEngineLaunch2 we will terminate
            // the process in IDebugEngineLaunch2.TerminateProcess

            Process.Terminate();

            return(VSConstants.S_OK);
        }
Beispiel #10
0
        /// <summary>
        /// Dispose
        /// </summary>
        public void Dispose()
        {
            if (TerminateOnDispose)
            {
                Process?.Terminate(NtStatus.STATUS_SUCCESS, false);
            }

            Process?.Close();
            Thread?.Close();
            ImageFile?.Close();
            SectionHandle?.Close();
            IFEOKeyHandle?.Close();
        }
 public void Dispose()
 {
     if (TerminateOnDispose)
     {
         try
         {
             Process?.Terminate(NtStatus.STATUS_PROCESS_IS_TERMINATING);
         }
         catch (NtException)
         {
         }
     }
     Process?.Dispose();
     Thread?.Dispose();
 }
Beispiel #12
0
 internal void Exit(int exitCode)
 {
     debugger.MTA2STA.Call(delegate { process.Terminate(); });
 }
 /// <summary>
 /// Terminate the process
 /// </summary>
 /// <param name="exitcode">The exit code for the termination</param>
 public void Terminate(NtStatus exitcode)
 {
     Process?.Terminate(exitcode);
 }
Beispiel #14
0
 public void Terminate(bool WaitForBreakOrEnd)
 {
     _process.Terminate(WaitForBreakOrEnd);
 }