ExeSessionProcess.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Globalization;
  5. using System.IO;
  6. using System.Threading;
  7. using Microsoft.Win32;
  8. using Microsoft.Win32.SafeHandles;
  9. using System.Runtime.InteropServices;
  10. namespace WinSCP
  11. {
  12. internal class ExeSessionProcess : IDisposable
  13. {
  14. public event OutputDataReceivedEventHandler OutputDataReceived;
  15. public bool HasExited { get { return _process.HasExited; } }
  16. public int ExitCode { get { return _process.ExitCode; } }
  17. public ExeSessionProcess(Session session)
  18. {
  19. _session = session;
  20. _logger = session.Logger;
  21. _incompleteLine = string.Empty;
  22. using (_logger.CreateCallstack())
  23. {
  24. string executablePath = GetExecutablePath();
  25. _logger.WriteLine("EXE executable path resolved to {0}", executablePath);
  26. string assemblyFilePath = _logger.GetAssemblyFilePath();
  27. FileVersionInfo assemblyVersion = null;
  28. if (assemblyFilePath != null)
  29. {
  30. assemblyVersion = FileVersionInfo.GetVersionInfo(assemblyFilePath);
  31. }
  32. CheckVersion(executablePath, assemblyVersion);
  33. string configSwitch;
  34. if (_session.DefaultConfiguration)
  35. {
  36. configSwitch = "/ini=nul ";
  37. }
  38. else
  39. {
  40. if (!string.IsNullOrEmpty(_session.IniFilePath))
  41. {
  42. configSwitch = string.Format(CultureInfo.InvariantCulture, "/ini=\"{0}\" ", _session.IniFilePath);
  43. }
  44. else
  45. {
  46. configSwitch = "";
  47. }
  48. }
  49. string logSwitch = null;
  50. if (!string.IsNullOrEmpty(_session.SessionLogPath))
  51. {
  52. logSwitch = string.Format(CultureInfo.InvariantCulture, "/log=\"{0}\" ", LogPathEscape(_session.SessionLogPath));
  53. }
  54. string xmlLogSwitch = string.Format(CultureInfo.InvariantCulture, "/xmllog=\"{0}\" ", LogPathEscape(_session.XmlLogPath));
  55. string assemblyVersionStr =
  56. (assemblyVersion == null) ? "unk" :
  57. string.Format(CultureInfo.InvariantCulture, "{0}{1}{2} ", assemblyVersion.ProductMajorPart, assemblyVersion.ProductMinorPart, assemblyVersion.ProductBuildPart);
  58. string assemblyVersionSwitch =
  59. string.Format(CultureInfo.InvariantCulture, "/dotnet={0} ", assemblyVersionStr);
  60. string arguments =
  61. xmlLogSwitch + "/xmlgroups /nointeractiveinput " + assemblyVersionSwitch +
  62. configSwitch + logSwitch + _session.AdditionalExecutableArguments;
  63. _process = new Process();
  64. _process.StartInfo.FileName = executablePath;
  65. _process.StartInfo.WorkingDirectory = Path.GetDirectoryName(executablePath);
  66. _process.StartInfo.Arguments = arguments;
  67. _process.StartInfo.UseShellExecute = false;
  68. _process.Exited += ProcessExited;
  69. if (_logger.Logging)
  70. {
  71. _process.OutputDataReceived += ProcessOutputDataReceived;
  72. _process.ErrorDataReceived += ProcessErrorDataReceived;
  73. }
  74. }
  75. }
  76. private static string LogPathEscape(string path)
  77. {
  78. return Session.ArgumentEscape(path).Replace("!", "!!");
  79. }
  80. public void Abort()
  81. {
  82. using (_logger.CreateCallstack())
  83. {
  84. lock (_lock)
  85. {
  86. if ((_process != null) && !_process.HasExited)
  87. {
  88. _process.Kill();
  89. }
  90. }
  91. }
  92. }
  93. public void Start()
  94. {
  95. using (_logger.CreateCallstack())
  96. {
  97. InitializeConsole();
  98. InitializeChild();
  99. }
  100. }
  101. private void InitializeChild()
  102. {
  103. using (_logger.CreateCallstack())
  104. {
  105. _process.StartInfo.Arguments += string.Format(CultureInfo.InvariantCulture, " /console /consoleinstance={0}", _instanceName);
  106. _logger.WriteLine("Starting \"{0}\" {1}", _process.StartInfo.FileName, _process.StartInfo.Arguments);
  107. _process.Start();
  108. _logger.WriteLine("Started process {0}", _process.Id);
  109. _thread = new Thread(ProcessEvents);
  110. _thread.IsBackground = true;
  111. _thread.Start();
  112. }
  113. }
  114. private void ProcessExited(object sender, EventArgs e)
  115. {
  116. _logger.WriteLine("Process {0} exited with exit code {1}", _process.Id, _process.ExitCode);
  117. }
  118. private void ProcessOutputDataReceived(object sender, DataReceivedEventArgs e)
  119. {
  120. _logger.WriteLine("Process output: {0}", e.Data);
  121. }
  122. private void ProcessErrorDataReceived(object sender, DataReceivedEventArgs e)
  123. {
  124. _logger.WriteLine("Process error output: {0}", e.Data);
  125. }
  126. private bool AbortedOrExited()
  127. {
  128. if (_abort)
  129. {
  130. _logger.WriteLine("Aborted");
  131. return true;
  132. }
  133. else if (_process.HasExited)
  134. {
  135. _logger.WriteLine("Exited");
  136. return true;
  137. }
  138. else
  139. {
  140. return false;
  141. }
  142. }
  143. private void ProcessEvents()
  144. {
  145. using (_logger.CreateCallstack())
  146. {
  147. while (!AbortedOrExited())
  148. {
  149. if (_requestEvent.WaitOne(100, false))
  150. {
  151. ProcessEvent();
  152. }
  153. }
  154. }
  155. }
  156. private void ProcessEvent()
  157. {
  158. using (_logger.CreateCallstack())
  159. {
  160. using (ConsoleCommStruct commStruct = AcquireCommStruct())
  161. {
  162. switch (commStruct.Event)
  163. {
  164. case ConsoleEvent.Print:
  165. ProcessPrintEvent(commStruct.PrintEvent);
  166. break;
  167. case ConsoleEvent.Input:
  168. ProcessInputEvent(commStruct.InputEvent);
  169. break;
  170. case ConsoleEvent.Choice:
  171. ProcessChoiceEvent(commStruct.ChoiceEvent);
  172. break;
  173. case ConsoleEvent.Title:
  174. ProcessTitleEvent(commStruct.TitleEvent);
  175. break;
  176. case ConsoleEvent.Init:
  177. ProcessInitEvent(commStruct.InitEvent);
  178. break;
  179. case ConsoleEvent.Progress:
  180. ProcessProgressEvent(commStruct.ProgressEvent);
  181. break;
  182. default:
  183. throw new NotImplementedException();
  184. }
  185. }
  186. _responseEvent.Set();
  187. }
  188. }
  189. private void ProcessChoiceEvent(ConsoleChoiceEventStruct e)
  190. {
  191. using (_logger.CreateCallstack())
  192. {
  193. if (e.Timeouting)
  194. {
  195. Thread.Sleep((int)e.Timer);
  196. e.Result = e.Timeouted;
  197. }
  198. else
  199. {
  200. e.Result = e.Break;
  201. }
  202. }
  203. }
  204. private void ProcessTitleEvent(ConsoleTitleEventStruct e)
  205. {
  206. using (_logger.CreateCallstack())
  207. {
  208. _logger.WriteLine("Not-supported title event [{0}]", e.Title);
  209. }
  210. }
  211. private void ProcessInputEvent(ConsoleInputEventStruct e)
  212. {
  213. using (_logger.CreateCallstack())
  214. {
  215. while (!AbortedOrExited())
  216. {
  217. lock (_input)
  218. {
  219. if (_input.Count > 0)
  220. {
  221. e.Str = _input[0];
  222. e.Result = true;
  223. _input.RemoveAt(0);
  224. Print(false, e.Str + "\n");
  225. return;
  226. }
  227. }
  228. _inputEvent.WaitOne(100, false);
  229. }
  230. }
  231. }
  232. private void Print(bool fromBeginning, string message)
  233. {
  234. if (fromBeginning && ((message.Length == 0) || (message[0] != '\n')))
  235. {
  236. _lastFromBeginning = message;
  237. _logger.WriteLine("Buffered from-beginning message [{0}]", _lastFromBeginning);
  238. }
  239. else
  240. {
  241. if (!string.IsNullOrEmpty(_lastFromBeginning))
  242. {
  243. AddToOutput(_lastFromBeginning);
  244. _lastFromBeginning = null;
  245. }
  246. if (fromBeginning && (message.Length > 0) && (message[0] == '\n'))
  247. {
  248. AddToOutput("\n");
  249. _lastFromBeginning = message.Substring(1);
  250. _logger.WriteLine("Buffered from-beginning message [{0}]", _lastFromBeginning);
  251. }
  252. else
  253. {
  254. AddToOutput(message);
  255. }
  256. }
  257. }
  258. private void AddToOutput(string message)
  259. {
  260. string[] lines = (_incompleteLine + message).Split(new[] { '\n' });
  261. _incompleteLine = lines[lines.Length - 1];
  262. for (int i = 0; i < lines.Length - 1; ++i)
  263. {
  264. if (OutputDataReceived != null)
  265. {
  266. OutputDataReceived(this, new OutputDataReceivedEventArgs(lines[i]));
  267. }
  268. }
  269. }
  270. private void ProcessPrintEvent(ConsolePrintEventStruct e)
  271. {
  272. Print(e.FromBeginning, e.Message);
  273. }
  274. private void ProcessInitEvent(ConsoleInitEventStruct e)
  275. {
  276. using (_logger.CreateCallstack())
  277. {
  278. e.InputType = 3; // pipe
  279. e.OutputType = 3; // pipe
  280. e.WantsProgress = _session.WantsProgress;
  281. }
  282. }
  283. private void ProcessProgressEvent(ConsoleProgressEventStruct e)
  284. {
  285. using (_logger.CreateCallstack())
  286. {
  287. _logger.WriteLine(
  288. "File Name [{0}] - Directory [{1}] - Overall Progress [{2}] - File Progress [{3}] - CPS [{4}]",
  289. e.FileName, e.Directory, e.OverallProgress, e.FileProgress, e.CPS);
  290. FileTransferProgressEventArgs args = new FileTransferProgressEventArgs();
  291. switch (e.Operation)
  292. {
  293. case ConsoleProgressEventStruct.ProgressOperation.Copy:
  294. args.Operation = ProgressOperation.Transfer;
  295. break;
  296. default:
  297. throw new ArgumentOutOfRangeException("Unknown progress operation", (Exception)null);
  298. }
  299. switch (e.Side)
  300. {
  301. case ConsoleProgressEventStruct.ProgressSide.Local:
  302. args.Side = ProgressSide.Local;
  303. break;
  304. case ConsoleProgressEventStruct.ProgressSide.Remote:
  305. args.Side = ProgressSide.Remote;
  306. break;
  307. default:
  308. throw new ArgumentOutOfRangeException("Unknown progress side", (Exception)null);
  309. }
  310. args.FileName = e.FileName;
  311. args.Directory = e.Directory;
  312. args.OverallProgress = ((double)e.OverallProgress) / 100;
  313. args.FileProgress = ((double)e.FileProgress) / 100;
  314. args.CPS = (int) e.CPS;
  315. _session.ProcessProgress(args);
  316. }
  317. }
  318. private void InitializeConsole()
  319. {
  320. using (_logger.CreateCallstack())
  321. {
  322. int attempts = 0;
  323. Random random = new Random();
  324. int process = Process.GetCurrentProcess().Id;
  325. do
  326. {
  327. if (attempts > MaxAttempts)
  328. {
  329. throw new SessionLocalException(_session, "Cannot find unique name for event object.");
  330. }
  331. int instanceNumber = random.Next(1000);
  332. _instanceName = string.Format(CultureInfo.InvariantCulture, "_{0}_{1}_{2}", process, GetHashCode(), instanceNumber);
  333. _logger.WriteLine("Trying event {0}", _instanceName);
  334. if (!TryCreateEvent(ConsoleEventRequest + _instanceName, out _requestEvent))
  335. {
  336. _logger.WriteLine("Event {0} is not unique", _instanceName);
  337. _requestEvent.Close();
  338. _requestEvent = null;
  339. }
  340. else
  341. {
  342. _logger.WriteLine("Event {0} is unique", _instanceName);
  343. _responseEvent = CreateEvent(ConsoleEventResponse + _instanceName);
  344. _cancelEvent = CreateEvent(ConsoleEventCancel + _instanceName);
  345. string fileMappingName = ConsoleMapping + _instanceName;
  346. _fileMapping = CreateFileMapping(fileMappingName);
  347. if (Marshal.GetLastWin32Error() == UnsafeNativeMethods.ERROR_ALREADY_EXISTS)
  348. {
  349. throw new SessionLocalException(_session, string.Format(CultureInfo.InvariantCulture, "File mapping {0} already exists", fileMappingName));
  350. }
  351. if (_fileMapping.IsInvalid)
  352. {
  353. throw new SessionLocalException(_session, string.Format(CultureInfo.InvariantCulture, "Cannot create file mapping {0}", fileMappingName));
  354. }
  355. }
  356. ++attempts;
  357. }
  358. while (_requestEvent == null);
  359. using (ConsoleCommStruct commStruct = AcquireCommStruct())
  360. {
  361. commStruct.InitHeader();
  362. }
  363. if (_session.GuardProcessWithJobInternal)
  364. {
  365. string jobName = ConsoleJob + _instanceName;
  366. _job = new Job(_logger, jobName);
  367. }
  368. }
  369. }
  370. private static SafeFileHandle CreateFileMapping(string fileMappingName)
  371. {
  372. return
  373. UnsafeNativeMethods.CreateFileMapping(
  374. new SafeFileHandle(new IntPtr(-1), true), IntPtr.Zero, FileMapProtection.PageReadWrite, 0,
  375. ConsoleCommStruct.Size, fileMappingName);
  376. }
  377. private ConsoleCommStruct AcquireCommStruct()
  378. {
  379. return new ConsoleCommStruct(_session, _fileMapping);
  380. }
  381. private bool TryCreateEvent(string name, out EventWaitHandle ev)
  382. {
  383. bool createdNew;
  384. _logger.WriteLine("Creating event {0}", name);
  385. ev = new EventWaitHandle(false, EventResetMode.AutoReset, name, out createdNew);
  386. _logger.WriteLine("Created event {0} with handle {1}, new {2}", name, ev.SafeWaitHandle.DangerousGetHandle(), createdNew);
  387. return createdNew;
  388. }
  389. private EventWaitHandle CreateEvent(string name)
  390. {
  391. EventWaitHandle ev;
  392. if (!TryCreateEvent(name, out ev))
  393. {
  394. throw new SessionLocalException(_session, string.Format(CultureInfo.InvariantCulture, "Event {0} already exists", name));
  395. }
  396. return ev;
  397. }
  398. private void TestEventClosed(string name)
  399. {
  400. if (_session.TestHandlesClosedInternal)
  401. {
  402. _logger.WriteLine("Testing that event {0} is closed", name);
  403. EventWaitHandle ev;
  404. if (TryCreateEvent(name, out ev))
  405. {
  406. ev.Close();
  407. }
  408. else
  409. {
  410. _logger.WriteLine("Exception: Event {0} was not closed yet", name);
  411. }
  412. }
  413. }
  414. public void ExecuteCommand(string command)
  415. {
  416. using (_logger.CreateCallstack())
  417. {
  418. lock (_input)
  419. {
  420. _input.Add(command);
  421. _inputEvent.Set();
  422. }
  423. }
  424. }
  425. public void Close()
  426. {
  427. using (_logger.CreateCallstack())
  428. {
  429. _logger.WriteLine("Waiting for process to exit");
  430. if (!_process.WaitForExit(1000))
  431. {
  432. _logger.WriteLine("Killing process");
  433. _process.Kill();
  434. }
  435. }
  436. }
  437. public void Dispose()
  438. {
  439. using (_logger.CreateCallstack())
  440. {
  441. lock (_lock)
  442. {
  443. if (_session.TestHandlesClosedInternal)
  444. {
  445. _logger.WriteLine("Will test that handles are closed");
  446. }
  447. _abort = true;
  448. if (_thread != null)
  449. {
  450. _thread.Join();
  451. _thread = null;
  452. }
  453. if (_process != null)
  454. {
  455. _process.Dispose();
  456. _process = null;
  457. }
  458. if (_requestEvent != null)
  459. {
  460. _requestEvent.Close();
  461. TestEventClosed(ConsoleEventRequest + _instanceName);
  462. }
  463. if (_responseEvent != null)
  464. {
  465. _responseEvent.Close();
  466. TestEventClosed(ConsoleEventResponse + _instanceName);
  467. }
  468. if (_cancelEvent != null)
  469. {
  470. _cancelEvent.Close();
  471. TestEventClosed(ConsoleEventCancel + _instanceName);
  472. }
  473. if (_fileMapping != null)
  474. {
  475. _fileMapping.Dispose();
  476. _fileMapping = null;
  477. if (_session.TestHandlesClosedInternal)
  478. {
  479. _logger.WriteLine("Testing that file mapping is closed");
  480. string fileMappingName = ConsoleMapping + _instanceName;
  481. SafeFileHandle fileMapping = CreateFileMapping(fileMappingName);
  482. if (Marshal.GetLastWin32Error() == UnsafeNativeMethods.ERROR_ALREADY_EXISTS)
  483. {
  484. _logger.WriteLine("Exception: File mapping {0} was not closed yet", fileMappingName);
  485. }
  486. if (!fileMapping.IsInvalid)
  487. {
  488. fileMapping.Dispose();
  489. }
  490. }
  491. }
  492. if (_inputEvent != null)
  493. {
  494. _inputEvent.Close();
  495. _inputEvent = null;
  496. }
  497. if (_job != null)
  498. {
  499. _job.Dispose();
  500. _job = null;
  501. }
  502. }
  503. }
  504. }
  505. private string GetExecutablePath()
  506. {
  507. using (_logger.CreateCallstack())
  508. {
  509. string executablePath;
  510. if (!string.IsNullOrEmpty(_session.ExecutablePath))
  511. {
  512. executablePath = _session.ExecutablePath;
  513. if (!File.Exists(executablePath))
  514. {
  515. throw new SessionLocalException(_session, string.Format(CultureInfo.CurrentCulture, "{0} does not exists.", executablePath));
  516. }
  517. }
  518. else
  519. {
  520. if (!TryFindExecutableInPath(GetAssemblyPath(), out executablePath) &&
  521. !TryFindExecutableInPath(GetInstallationPath(Registry.CurrentUser), out executablePath) &&
  522. !TryFindExecutableInPath(GetInstallationPath(Registry.LocalMachine), out executablePath) &&
  523. !TryFindExecutableInPath(GetDefaultInstallationPath(), out executablePath))
  524. {
  525. throw new SessionLocalException(_session,
  526. string.Format(CultureInfo.CurrentCulture,
  527. "The {0} executable was not found at location of the assembly ({1}), nor in an installation path. You may use Session.ExecutablePath property to explicitly set path to {0}.",
  528. ExeExecutableFileName, GetAssemblyPath()));
  529. }
  530. }
  531. return executablePath;
  532. }
  533. }
  534. private static string GetDefaultInstallationPath()
  535. {
  536. return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "WinSCP");
  537. }
  538. private static string GetInstallationPath(RegistryKey rootKey)
  539. {
  540. RegistryKey key = rootKey.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Uninstall\winscp3_is1");
  541. return (key != null) ? (string)key.GetValue("Inno Setup: App Path") : null;
  542. }
  543. private bool TryFindExecutableInPath(string path, out string result)
  544. {
  545. if (string.IsNullOrEmpty(path))
  546. {
  547. result = null;
  548. }
  549. else
  550. {
  551. string executablePath = Path.Combine(path, ExeExecutableFileName);
  552. if (File.Exists(executablePath))
  553. {
  554. result = executablePath;
  555. _logger.WriteLine("Executable found in {0}", executablePath);
  556. }
  557. else
  558. {
  559. result = null;
  560. _logger.WriteLine("Executable not found in {0}", executablePath);
  561. }
  562. }
  563. return (result != null);
  564. }
  565. private string GetAssemblyPath()
  566. {
  567. string codeBasePath = _logger.GetAssemblyFilePath();
  568. string path = null;
  569. if (!string.IsNullOrEmpty(codeBasePath))
  570. {
  571. path = Path.GetDirectoryName(codeBasePath);
  572. Debug.Assert(path != null);
  573. }
  574. return path;
  575. }
  576. private void CheckVersion(string exePath, FileVersionInfo assemblyVersion)
  577. {
  578. using (_logger.CreateCallstack())
  579. {
  580. FileVersionInfo version = FileVersionInfo.GetVersionInfo(exePath);
  581. _logger.WriteLine("Version of {0} is {1}, product {2} version is {3}", exePath, version.FileVersion, version.ProductName, version.ProductVersion);
  582. if (_session.DisableVersionCheck)
  583. {
  584. _logger.WriteLine("Version check disabled (not recommended)");
  585. }
  586. else if (assemblyVersion == null)
  587. {
  588. _logger.WriteLine("Assembly version not known, cannot check version");
  589. }
  590. else if (assemblyVersion.ProductVersion != version.ProductVersion)
  591. {
  592. throw new SessionLocalException(
  593. _session, string.Format(CultureInfo.CurrentCulture,
  594. "The version of {0} ({1}) does not match version of this assembly {2} ({3}). You can disable this check using Session.DisableVersionCheck (not recommended).",
  595. exePath, version.ProductVersion, _logger.GetAssemblyFilePath(), assemblyVersion.ProductVersion));
  596. }
  597. }
  598. }
  599. public void WriteStatus()
  600. {
  601. string executablePath = GetExecutablePath();
  602. _logger.WriteLine("{0} - exists [{1}]", executablePath, File.Exists(executablePath));
  603. }
  604. private const int MaxAttempts = 10;
  605. private const string ConsoleMapping = "WinSCPConsoleMapping";
  606. private const string ConsoleEventRequest = "WinSCPConsoleEventRequest";
  607. private const string ConsoleEventResponse = "WinSCPConsoleEventResponse";
  608. private const string ConsoleEventCancel = "WinSCPConsoleEventCancel";
  609. private const string ConsoleJob = "WinSCPConsoleJob";
  610. private const string ExeExecutableFileName = "winscp.exe";
  611. private Process _process;
  612. private readonly object _lock = new object();
  613. private readonly Logger _logger;
  614. private readonly Session _session;
  615. private EventWaitHandle _requestEvent;
  616. private EventWaitHandle _responseEvent;
  617. private EventWaitHandle _cancelEvent;
  618. private SafeFileHandle _fileMapping;
  619. private string _instanceName;
  620. private Thread _thread;
  621. private bool _abort;
  622. private string _lastFromBeginning;
  623. private string _incompleteLine;
  624. private readonly List<string> _input = new List<string>();
  625. private AutoResetEvent _inputEvent = new AutoResetEvent(false);
  626. private Job _job;
  627. }
  628. }