Issues when upgrading project from Unity 2022.3.30f1 to Unity 6000.0.30f1

Using Unity 2022.3.30f1, I have a project with the following code:

using System;
using System.Diagnostics;
using System.IO;
using UnityEngine;

public class ShellCommands : MonoBehaviour {

    private void Start() {
        SetGpioDirection("gpio137");
    }

    public static void SetGpioDirection(string gpioPin) {
        string command = "echo out > /sys/class/gpio/" + gpioPin + "/direction"; // OUTPUT
        _ = ShellCommands.ExecuteCommandShellWithADMINSU(command);  //_ = porque não preciso do valor de retorno da função
    }

    public static string ExecuteCommandShellWithADMINSU(string command) {
        if (string.IsNullOrEmpty(command)) {
            UnityEngine.Debug.LogError("Command is null");
            return null;
        }

        Process process = null;
        StreamWriter writer = null;
        StreamReader outputReader = null;
        StreamReader errorReader = null;
        string commandReturn = null;

        try {
            process = new Process();
            process.StartInfo.FileName = "su"; // "su";
            process.StartInfo.UseShellExecute = false;
            process.StartInfo.RedirectStandardInput = true;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.RedirectStandardError = true;
            process.StartInfo.CreateNoWindow = true; // Oculta a janela do processo

            process.Start();
            writer = process.StandardInput;
            outputReader = process.StandardOutput;
            errorReader = process.StandardError;

            writer.WriteLine(command);
            writer.Flush();
            writer.WriteLine("exit");
            writer.Flush();

            commandReturn = outputReader.ReadToEnd();
            string errorOutput = errorReader.ReadToEnd();

            if (!string.IsNullOrEmpty(errorOutput) && !errorOutput.Trim().Equals("allowed", StringComparison.OrdinalIgnoreCase)) {
                UnityEngine.Debug.LogError("Error Output: " + errorOutput);
            }
            else {
                UnityEngine.Debug.Log("Superuser access granted.");
            }
        }
        catch (Exception e) {
            UnityEngine.Debug.LogError("Error executing command: " + e.Message);
        }
        finally {
            if (writer != null) {
                writer.Close();
            }
            if (outputReader != null) {
                outputReader.Close();
            }
            if (errorReader != null) {
                errorReader.Close();
            }
            if (process != null) {
                process.Close();
            }
        }
        return commandReturn;
    }
}

I’m developing an application for an Android device that already has root access. Compiling the project with Unity 2022, everything works fine.

Now, using Unity 6, this code simply causes the following error:
Error executing command: ApplicationName=‘su’, CommandLine=‘’, CurrentDirectory=‘’, Native error= Success
UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
ShellCommands:ExecuteCommandShellWithADMINSU(String)
ShellCommands:Start()

What changed from Unity 2022.3 to Unity 6 that is causing this issue?

For one I know that Process was never ported to IL2CPP.

Perhaps Unity6 removed the Mono Scripting backend for Android, forcing you into IL2CPP?

More reading:

System Process not implemented in IL2CPP targets: