ExeSessionProcess.cs 27 KB

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