mirror of
https://github.com/microsoft/terminal.git
synced 2025-12-10 18:43:54 -06:00
As VS 2022 doesn't seem to store files with UTF-8 BOM as often anymore, we've been getting more and more pull requests which seemingly randomly change files. This cleans the situation up by removing the BOM from all files that have one. Additionally, `Host.Tests.Feature.rc` was converted from UTF-16 to UTF-8.
71 lines
1.8 KiB
C#
71 lines
1.8 KiB
C#
using System;
|
|
using System.Runtime.InteropServices;
|
|
using static GUIConsole.ConPTY.Native.ProcessApi;
|
|
|
|
namespace GUIConsole.ConPTY.Processes
|
|
{
|
|
/// <summary>
|
|
/// Represents an instance of a process.
|
|
/// </summary>
|
|
internal sealed class Process : IDisposable
|
|
{
|
|
public Process(STARTUPINFOEX startupInfo, PROCESS_INFORMATION processInfo)
|
|
{
|
|
StartupInfo = startupInfo;
|
|
ProcessInfo = processInfo;
|
|
}
|
|
|
|
public STARTUPINFOEX StartupInfo { get; }
|
|
public PROCESS_INFORMATION ProcessInfo { get; }
|
|
|
|
#region IDisposable Support
|
|
|
|
private bool disposedValue = false; // To detect redundant calls
|
|
|
|
void Dispose(bool disposing)
|
|
{
|
|
if (!disposedValue)
|
|
{
|
|
if (disposing)
|
|
{
|
|
// dispose managed state (managed objects).
|
|
}
|
|
|
|
// dispose unmanaged state
|
|
|
|
// Free the attribute list
|
|
if (StartupInfo.lpAttributeList != IntPtr.Zero)
|
|
{
|
|
DeleteProcThreadAttributeList(StartupInfo.lpAttributeList);
|
|
Marshal.FreeHGlobal(StartupInfo.lpAttributeList);
|
|
}
|
|
|
|
// Close process and thread handles
|
|
if (ProcessInfo.hProcess != IntPtr.Zero)
|
|
{
|
|
CloseHandle(ProcessInfo.hProcess);
|
|
}
|
|
if (ProcessInfo.hThread != IntPtr.Zero)
|
|
{
|
|
CloseHandle(ProcessInfo.hThread);
|
|
}
|
|
|
|
disposedValue = true;
|
|
}
|
|
}
|
|
|
|
~Process()
|
|
{
|
|
Dispose(false);
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
Dispose(true);
|
|
GC.SuppressFinalize(this);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|