Skip to content

Improve Process support on MacCatalyst #126472

@adamsitnik

Description

@adamsitnik
  1. Performance: prefer posix_spawn when available (it has provide up to x100 boost on macOS arm64). It's a matter of extending what Prefer posix_spawn on OSX #126063 did by adding || defined(TARGET_MACCATALYST) here:
- #if defined(TARGET_OSX)
+ #if defined(TARGET_OSX) || defined(TARGET_MACCATALYST)
  1. Perform IsTerminal check for MacCatalyst:

We never performed the extra configuration on these platforms:

For IsiOSLike platforms:

<IsiOSLike Condition="'$(TargetPlatformIdentifier)' == 'maccatalyst' or '$(TargetPlatformIdentifier)' == 'ios' or '$(TargetPlatformIdentifier)' == 'tvos'">true</IsiOSLike>

We were including:

<ItemGroup Condition="'$(TargetPlatformIdentifier)' != '' and '$(TargetPlatformIdentifier)' != 'windows' and '$(IsiOSLike)' == 'true'">
<Compile Include="System\Diagnostics\Process.ConfigureTerminalForChildProcesses.iOS.cs" />
</ItemGroup>

That was a nop:

public partial class Process
{
/// These methods are used on other Unix systems to track how many children use the terminal,
/// and update the terminal configuration when necessary.
[Conditional("unnecessary")]
internal static void ConfigureTerminalForChildProcesses(int increment, bool configureConsole = true)
{
}
static partial void SetDelayedSigChildConsoleConfigurationHandler();
private static bool AreChildrenUsingTerminal => false;
}
}

The fix will be to stop treating MacCatalyst as iOSLike in the project file:

<IsiOSLike Condition="'$(TargetPlatformIdentifier)' == 'maccatalyst' or '$(TargetPlatformIdentifier)' == 'ios' or '$(TargetPlatformIdentifier)' == 'tvos'">true</IsiOSLike>

and extend pal_log.m (context) with sth like:

int32_t SystemNative_IsATty(intptr_t fd)
{
#if defined(TARGET_MACCATALYST)
    return isatty(ToFileDescriptor(fd));
#elif defined(TARGET_IOS) || defined(TARGET_TVOS)
    // there is no terminal on these platforms
    (void)fd;
    return 0;
#endif
}

We need to get #126306 merged first and ensure all the MacCatalyst and iOS builds and tests are green.

Metadata

Metadata

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions