mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-29 16:11:05 +01:00
Process stuff is pain
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Win32.SafeHandles;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
@@ -32,6 +33,8 @@ namespace Tgstation.Server.Host.System
|
||||
|
||||
readonly global::System.Diagnostics.Process handle;
|
||||
|
||||
readonly SafeProcessHandle safeHandle;
|
||||
|
||||
readonly Task<string> standardOutputTask;
|
||||
readonly Task<string> standardErrorTask;
|
||||
readonly StringBuilder combinedStringBuilder;
|
||||
@@ -62,6 +65,9 @@ namespace Tgstation.Server.Host.System
|
||||
// Do this fast because the runtime will bitch if we try to access it after it ends
|
||||
Id = handle.Id;
|
||||
|
||||
// https://stackoverflow.com/a/47656845
|
||||
safeHandle = handle.SafeHandle;
|
||||
|
||||
this.processFeatures = processFeatures ?? throw new ArgumentNullException(nameof(processFeatures));
|
||||
|
||||
this.standardOutputTask = standardOutputTask;
|
||||
@@ -98,7 +104,11 @@ namespace Tgstation.Server.Host.System
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose() => handle.Dispose();
|
||||
public void Dispose()
|
||||
{
|
||||
safeHandle.Dispose();
|
||||
handle.Dispose();
|
||||
}
|
||||
|
||||
async Task<int> WrapLifetimeTask(Task<int> lifetimeTask)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user