Skip to content

Commit

Permalink
Replace putenv() with setenv()
Browse files Browse the repository at this point in the history
The use of `putenv()` is discouraged for portability reasons:
https://pubs.opengroup.org/onlinepubs/9799919799/functions/putenv.html
  • Loading branch information
sicherha committed Dec 25, 2024
1 parent 26493c0 commit afd2fab
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/subprocess-unix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ void process_run_subcommand(Context<E> &ctx, int argc, char **argv) {
std::string dso_path = find_dso(ctx, self);

// Set environment variables
putenv(strdup(("LD_PRELOAD=" + dso_path).c_str()));
putenv(strdup(("MOLD_PATH=" + self).c_str()));
setenv("LD_PRELOAD", dso_path.c_str(), 1);
setenv("MOLD_PATH", self.c_str(), 1);

// If ld, ld.lld or ld.gold is specified, run mold itself
if (std::string cmd = path_filename(argv[2]);
Expand Down

0 comments on commit afd2fab

Please sign in to comment.