The Linux implementation allocates an array of native utf8 strings that are null terminated when mapping managed env vars to native env vars:
|
UnixHelpers.AllocNullTerminatedArray(envp, ref envpPtr); |
We should detect the case when ProcessStartOptions.HasEnvironmentBeenAccessed returns false and do the following:
- don't access
ProcessStartOptions.Environment to avoid allocations
- don't allocate the native memory here:
|
UnixHelpers.AllocNullTerminatedArray(envp, ref envpPtr); |
- just pass
null to the native layer and make it pass environ directly to execve.
By doing that we are going to avoid needles utf8->unicode->utf8 converstion for all the env vars in case where user has not modified the env vars and the process should simply derive the env vars from parent.
The Linux implementation allocates an array of native utf8 strings that are null terminated when mapping managed env vars to native env vars:
ProcessPlayground/Library/SafeChildProcessHandle.Linux.cs
Line 125 in b361571
We should detect the case when
ProcessStartOptions.HasEnvironmentBeenAccessedreturns false and do the following:ProcessStartOptions.Environmentto avoid allocationsProcessPlayground/Library/SafeChildProcessHandle.Linux.cs
Line 125 in b361571
nullto the native layer and make it passenvirondirectly toexecve.By doing that we are going to avoid needles utf8->unicode->utf8 converstion for all the env vars in case where user has not modified the env vars and the process should simply derive the env vars from parent.