Export upcxx::getenv_console()

Issue #137 resolved
Dan Bonachea created an issue

With the merge of pull request #61, impl issue 100 is now resolved and the implementation should always be respecting environment variables set in the spawning console (or batch script), even on loosely coupled systems where the spawner doesn't normally propagate the POSIX environment across processes. We'd like to export this facility to also give applications the ability to portably retrieve environment variables set in the spawning console, without requiring them to manually propagate env settings in their job spawn command line (as is common with some cluster-based mpiruns).

The minimal change would be to export a drop-in replacement for std::getenv():

char *upcxx::getenv_console( const char * env_var );
// Precondition: the UPC++ library must be in an initialized state
// Semantics: On some systems, environment variables set on the spawning console might 
// not be propagated to the POSIX environment of all processes. 
// This function's semantics are the same as std::getenv(), except that if `env_var` was set 
// in the environment of the spawning console, that value is instead returned.
// It is unspecified whether std::setenv, std::unsetenv, std::putenv affect the contents 
// of the spawning console environment.

the implementation work is trivial, as it's just a simple wrapper around gasnett_getenv.

We could optionally go further and expose a class interface for querying environment variables with automatic defaulting like the current src/os_env.hpp, however that's not strictly necessary and seems generally orthogonal to UPC++'s feature set.

This doesn't really fit in any of the existing spec chapters, the closest is probably Ch 2 Init/Finalize.

Comments (5)

  1. Log in to comment