-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Remove redundant P/Invoke-s in S.D.Process on Apple platforms #54273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6599d53
dc7f472
ed331c6
b52c7f0
e3b59d6
a455e85
f24f72d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Threading; | ||
|
||
namespace System.Diagnostics | ||
{ | ||
public partial class Process | ||
{ | ||
private static int s_childrenUsingTerminalCount; | ||
|
||
static partial void ConfigureTerminalForChildProcessesInner(int increment) | ||
{ | ||
Debug.Assert(increment != 0); | ||
|
||
int childrenUsingTerminalRemaining = Interlocked.Add(ref s_childrenUsingTerminalCount, increment); | ||
if (increment > 0) | ||
{ | ||
Debug.Assert(s_processStartLock.IsReadLockHeld); | ||
|
||
// At least one child is using the terminal. | ||
Interop.Sys.ConfigureTerminalForChildProcess(childUsesTerminal: true); | ||
} | ||
else | ||
{ | ||
Debug.Assert(s_processStartLock.IsWriteLockHeld); | ||
|
||
if (childrenUsingTerminalRemaining == 0) | ||
{ | ||
// No more children are using the terminal. | ||
Interop.Sys.ConfigureTerminalForChildProcess(childUsesTerminal: false); | ||
} | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,6 @@ public partial class Process : IDisposable | |
private static volatile bool s_initialized; | ||
private static readonly object s_initializedGate = new object(); | ||
private static readonly ReaderWriterLockSlim s_processStartLock = new ReaderWriterLockSlim(); | ||
private static int s_childrenUsingTerminalCount; | ||
|
||
/// <summary> | ||
/// Puts a Process component in state to interact with operating system processes that run in a | ||
|
@@ -1051,26 +1050,9 @@ private static void OnSigChild(int reapAll) | |
/// </summary> | ||
internal static void ConfigureTerminalForChildProcesses(int increment) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not think you need the ConfigureTerminalForChildProcesses / ConfigureTerminalForChildProcessesInner split. ConfigureTerminalForChildProcesses can be the partial method. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmmm, that's annoying. |
||
{ | ||
Debug.Assert(increment != 0); | ||
|
||
int childrenUsingTerminalRemaining = Interlocked.Add(ref s_childrenUsingTerminalCount, increment); | ||
if (increment > 0) | ||
{ | ||
Debug.Assert(s_processStartLock.IsReadLockHeld); | ||
|
||
// At least one child is using the terminal. | ||
Interop.Sys.ConfigureTerminalForChildProcess(childUsesTerminal: true); | ||
} | ||
else | ||
{ | ||
Debug.Assert(s_processStartLock.IsWriteLockHeld); | ||
|
||
if (childrenUsingTerminalRemaining == 0) | ||
{ | ||
// No more children are using the terminal. | ||
Interop.Sys.ConfigureTerminalForChildProcess(childUsesTerminal: false); | ||
} | ||
} | ||
ConfigureTerminalForChildProcessesInner(increment); | ||
} | ||
|
||
static partial void ConfigureTerminalForChildProcessesInner(int increment); | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.