-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove redundant P/Invoke-s in S.D.Process on Apple platforms (#54273)
* Remove P/Invoke to SystemNative_ConfigureTerminalForChildProcess which doesn't exist on Apple platforms * Address the feedback based on the ifdef approach * Add IsiOSLike property * Use a partial method approach * Address the feedback
- Loading branch information
1 parent
30f4269
commit f891033
Showing
3 changed files
with
47 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...nostics.Process/src/System/Diagnostics/Process.Unix.ConfigureTerminalForChildProcesses.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters