@@ -262,14 +262,16 @@ struct Crystal::System::Process
262262 def self.spawn (prepared_args, env, clear_env, input, output, error, chdir)
263263 r, w = FileDescriptor .system_pipe
264264
265+ envp = Env .make_envp(env, clear_env)
266+
265267 pid = fork(will_exec: true ) do
266268 Crystal ::System ::Signal .after_fork_before_exec
267269 end
268270
269271 if ! pid
270272 LibC .close(r)
271273 begin
272- self .try_replace(prepared_args, env, clear_env , input, output, error, chdir)
274+ self .try_replace(prepared_args, envp , input, output, error, chdir)
273275 byte = 1 _u8
274276 errno = Errno .value.to_i32
275277 FileDescriptor .write_fully(w, pointerof (byte))
@@ -337,12 +339,11 @@ struct Crystal::System::Process
337339 {pathname, argv.to_unsafe}
338340 end
339341
340- private def self.try_replace (prepared_args , env , clear_env , input , output , error , chdir )
342+ private def self.try_replace (prepared_args , envp , input , output , error , chdir )
341343 reopen_io(input, ORIGINAL_STDIN )
342344 reopen_io(output, ORIGINAL_STDOUT )
343345 reopen_io(error, ORIGINAL_STDERR )
344346
345- envp = Env .make_envp(env, clear_env)
346347 ::Dir .cd(chdir) if chdir
347348
348349 execvpe(* prepared_args, envp)
@@ -456,7 +457,9 @@ struct Crystal::System::Process
456457 end
457458
458459 def self.replace (command, prepared_args, env, clear_env, input, output, error, chdir)
459- try_replace(prepared_args, env, clear_env, input, output, error, chdir)
460+ envp = Env .make_envp(env, clear_env)
461+
462+ try_replace(prepared_args, envp, input, output, error, chdir)
460463 raise_exception_from_errno(command)
461464 end
462465
0 commit comments