Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

util/environ: use setenv() if available #1353

Merged
merged 1 commit into from
Jul 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/pmix.m4
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ AC_DEFUN([PMIX_SETUP_CORE],[
# -lrt might be needed for clock_gettime
PMIX_SEARCH_LIBS_CORE([clock_gettime], [rt])

AC_CHECK_FUNCS([asprintf snprintf vasprintf vsnprintf strsignal socketpair strncpy_s usleep statfs statvfs getpeereid getpeerucred strnlen posix_fallocate tcgetpgrp setpgid ptsname openpty])
AC_CHECK_FUNCS([asprintf snprintf vasprintf vsnprintf strsignal socketpair strncpy_s usleep statfs statvfs getpeereid getpeerucred strnlen posix_fallocate tcgetpgrp setpgid ptsname openpty setenv])

# On some hosts, htonl is a define, so the AC_CHECK_FUNC will get
# confused. On others, it's in the standard library, but stubbed with
Expand Down
8 changes: 8 additions & 0 deletions src/util/pmix_environ.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* reserved.
* Copyright (c) 2014-2017 Intel, Inc. All rights reserved.
* Copyright (c) 2016 IBM Corporation. All rights reserved.
* Copyright (c) 2019 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -129,7 +131,13 @@ char **pmix_environ_merge(char **minor, char **major)
astonishmet for PMIX developers (i.e., those that don't
check the return code of pmix_setenv() and notice that we
returned an error if you passed in the real environ) */
#if defined (HAVE_SETENV)
setenv(name, value, overwrite);
/* setenv copies the value, so we can free it here */
free(newvalue);
#else
putenv(newvalue);
#endif
return PMIX_SUCCESS;
}

Expand Down