1 //
2 // Copyright (c) 2010-2018 Antmicro
3 //
4 // This file is licensed under the MIT License.
5 // Full license text is available in 'licenses/MIT.txt'.
6 //
7 #if PLATFORM_LINUX
8 using System.Diagnostics;
9 
10 namespace Antmicro.Renode.UI
11 {
12     [ConsoleBackendAnalyzerProvider("Putty")]
13     public class PuttyProvider : ProcessBasedProvider
14     {
CreateProcess(string consoleName, string command)15         protected override Process CreateProcess(string consoleName, string command)
16         {
17             var p = new Process();
18             p.EnableRaisingEvents = true;
19             var arguments = string.Format("{0} -serial -title '{0}'", consoleName);
20             p.StartInfo = new ProcessStartInfo("putty", arguments)
21             {
22                 UseShellExecute = false,
23                 RedirectStandardError = true,
24                 RedirectStandardOutput = true,
25                 RedirectStandardInput = true
26             };
27             p.Exited += (sender, e) =>
28             {
29                 var proc = sender as Process;
30                 if (proc.ExitCode != 0)
31                 {
32                     LogError("Putty", arguments, proc.ExitCode);
33                 }
34                 InnerOnClose();
35             };
36 
37             return p;
38         }
39     }
40 }
41 
42 #endif
43