src/Cassandra.IntegrationTests/TestClusterManagement/CcmBridge.cs
/// <summary>
/// Spawns a new process (platform independent)
/// </summary>
Spawns a new process (platform independent)
Spawns a new process ( platform independent )
public static ProcessOutput ExecuteProcess(string processName, string args, int timeout = DefaultCmdTimeout)
        {
            var output = new ProcessOutput();
            using (var process = new Process())
            {
                process.StartInfo.FileName = processName;
                process.StartInfo.Arguments = args;
                process.StartInfo.RedirectStandardOutput = true;
                process.StartInfo.RedirectStandardError = true;
                process.StartInfo.UseShellExecute = false;
                process.StartInfo.CreateNoWindow = true;
#if !NETCORE
                process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
#endif
                using (var outputWaitHandle = new AutoResetEvent(false))
                using (var errorWaitHandle = new AutoResetEvent(false))
                {
                    process.OutputDataReceived += (sender, e) =>
                    {
                        if (e.Data == null)
                        {
                            try
                            {
                                outputWaitHandle.Set();
                            }
                            catch
                            {
                            }
                        }
                        else
                        {
                            output.OutputText.AppendLine(e.Data);
                        }
                    };
                    process.ErrorDataReceived += (sender, e) =>
                    {
                        if (e.Data == null)
                        {
                            try
                            {
                                errorWaitHandle.Set();
                            }
                            catch
                            {
                            }
                        }
                        else
                        {
                            output.OutputText.AppendLine(e.Data);
                        }
                    };
                    process.Start();
                    process.BeginOutputReadLine();
                    process.BeginErrorReadLine();
                    if (process.WaitForExit(timeout) &&
                        outputWaitHandle.WaitOne(timeout) &&
                        errorWaitHandle.WaitOne(timeout))
                    {
                        output.ExitCode = process.ExitCode;
                    }
                    else
                    {
                        output.ExitCode = -1;
                    }
                }
            }
            return output;
        }
public static ProcessOutput ExecuteProcess ( string processName , string args , int timeout = DefaultCmdTimeout ) { var output = new ProcessOutput ( ) ; using ( var process = new Process ( ) ) { process . StartInfo . FileName = processName ; process . StartInfo . Arguments = args ; process . StartInfo . RedirectStandardOutput = true ; process . StartInfo . RedirectStandardError = true ; process . StartInfo . UseShellExecute = false ; process . StartInfo . CreateNoWindow = true ; if ! NETCORE process . StartInfo . WindowStyle = ProcessWindowStyle . Hidden ; endif using ( var outputWaitHandle = new AutoResetEvent ( false ) ) using ( var errorWaitHandle = new AutoResetEvent ( false ) ) { process . OutputDataReceived += ( sender , e ) => { if ( e . Data == null ) { try { outputWaitHandle . Set ( ) ; } catch { } } else { output . OutputText . AppendLine ( e . Data ) ; } } ; process . ErrorDataReceived += ( sender , e ) => { if ( e . Data == null ) { try { errorWaitHandle . Set ( ) ; } catch { } } else { output . OutputText . AppendLine ( e . Data ) ; } } ; process . Start ( ) ; process . BeginOutputReadLine ( ) ; process . BeginErrorReadLine ( ) ; if ( process . WaitForExit ( timeout ) && outputWaitHandle . WaitOne ( timeout ) && errorWaitHandle . WaitOne ( timeout ) ) { output . ExitCode = process . ExitCode ; } else { output . ExitCode = - 1 ; } } } return output ; }
Spawns a new process (platform independent)
Spawns a new process ( platform independent )
//Hide the python window if possible //probably is already disposed //probably is already disposed // Process completed. // Timed out.
processName
string
args
string
timeout
int