Allow to unset LD_LIBRARY_PATH on exec
This is useful when using distro-packaged video-tools (e.g. on Linux/ARM), or when running post-export commands.
This commit is contained in:
parent
0b5e502546
commit
82d491cb80
|
@ -28,9 +28,9 @@ namespace ARDOUR {
|
|||
class LIBARDOUR_API SystemExec : public PBD::SystemExec
|
||||
{
|
||||
public:
|
||||
SystemExec (std::string c, std::string a = "");
|
||||
SystemExec (std::string c, char** a);
|
||||
SystemExec (std::string c, const std::map<char, std::string> subs);
|
||||
SystemExec (std::string cmd, std::string argv = "", bool supress_ld_env = false);
|
||||
SystemExec (std::string cmd, char** argv, bool supress_ld_env = false);
|
||||
SystemExec (std::string cmd, const std::map<char, std::string> subs, bool supress_ld_env = false);
|
||||
~SystemExec ();
|
||||
|
||||
int start (StdErrMode stderr_mode = IgnoreAndClose)
|
||||
|
|
|
@ -56,20 +56,20 @@ SystemExec::initialize ()
|
|||
_initialized = true;
|
||||
}
|
||||
|
||||
SystemExec::SystemExec (std::string c, char** a)
|
||||
: PBD::SystemExec (c, a)
|
||||
SystemExec::SystemExec (std::string cmd, char** argv, bool supress_ld_env)
|
||||
: PBD::SystemExec (cmd, argv, supress_ld_env)
|
||||
{
|
||||
initialize ();
|
||||
}
|
||||
|
||||
SystemExec::SystemExec (std::string c, std::string a)
|
||||
: PBD::SystemExec (c, a)
|
||||
SystemExec::SystemExec (std::string cmd, std::string argv, bool supress_ld_env)
|
||||
: PBD::SystemExec (cmd, argv, supress_ld_env)
|
||||
{
|
||||
initialize ();
|
||||
}
|
||||
|
||||
SystemExec::SystemExec (std::string c, const std::map<char, std::string> subs)
|
||||
: PBD::SystemExec (c, subs)
|
||||
SystemExec::SystemExec (std::string cmd, const std::map<char, std::string> subs, bool supress_ld_env)
|
||||
: PBD::SystemExec (cmd, subs, supress_ld_env)
|
||||
{
|
||||
initialize ();
|
||||
}
|
||||
|
|
|
@ -82,22 +82,23 @@ class LIBPBD_API SystemExec
|
|||
* The alternative constructor below allows to specify quoted parameters
|
||||
* incl. whitespace.
|
||||
*
|
||||
* @param c program pathname that identifies the new process image file.
|
||||
* @param a string of commandline-arguments to be passed to the new program.
|
||||
* @param cmd program pathname that identifies the new process image file.
|
||||
* @param argv string of commandline-arguments to be passed to the new program.
|
||||
* @param supress_ld_env On Linux, unset LD_LIBRARY_PATH environment variable
|
||||
*/
|
||||
SystemExec (std::string c, std::string a = "");
|
||||
SystemExec (std::string cmd, std::string argv = "", bool supress_ld_env = false);
|
||||
/** similar to \ref SystemExec but allows to specify custom arguments
|
||||
*
|
||||
* @param c program pathname that identifies the new process image file.
|
||||
* @param a array of argument strings passed to the new program as 'argv'.
|
||||
* @param cmd program pathname that identifies the new process image file.
|
||||
* @param argv array of argument strings passed to the new program as 'argv'.
|
||||
* it must be terminated by a null pointer (see the 'evecve'
|
||||
* POSIX-C documentation for more information)
|
||||
* The array must be dynamically allocated using malloc or strdup.
|
||||
* Unless they're NULL, the array itself and each of its content
|
||||
* memory is freed() in the destructor.
|
||||
*
|
||||
* @param supress_ld_env On Linux, unset LD_LIBRARY_PATH environment variable
|
||||
*/
|
||||
SystemExec (std::string c, char ** a);
|
||||
SystemExec (std::string cmd, char **argv, bool supress_ld_env = false);
|
||||
|
||||
/** similar to \ref SystemExec but expects a whole command line, and
|
||||
* handles some simple escape sequences.
|
||||
|
@ -111,10 +112,9 @@ class LIBPBD_API SystemExec
|
|||
* "\ " is non-splitting space, "\\" (and "\" at end of command) as "\",
|
||||
* for "%<char>", \<char\> is looked up in subs and the corresponding string
|
||||
* substituted. "%%" (and "%" at end of command)
|
||||
*
|
||||
* @returns an argv array suitable for creating a new SystemExec with
|
||||
* @param supress_ld_env On Linux, unset LD_LIBRARY_PATH environment variable
|
||||
*/
|
||||
SystemExec (std::string command, const std::map<char, std::string> subs);
|
||||
SystemExec (std::string command, const std::map<char, std::string> subs, bool supress_ld_env = false);
|
||||
|
||||
virtual ~SystemExec ();
|
||||
|
||||
|
@ -231,7 +231,7 @@ class LIBPBD_API SystemExec
|
|||
|
||||
void make_argp(std::string);
|
||||
void make_argp_escaped(std::string command, const std::map<char, std::string> subs);
|
||||
void make_envp();
|
||||
void make_envp (bool supress_ld_env);
|
||||
|
||||
char **argp;
|
||||
char **envp;
|
||||
|
|
|
@ -79,17 +79,17 @@ SystemExec::init ()
|
|||
#endif
|
||||
}
|
||||
|
||||
SystemExec::SystemExec (std::string c, std::string a)
|
||||
SystemExec::SystemExec (std::string c, std::string a, bool supress_ld_env)
|
||||
: cmd(c)
|
||||
{
|
||||
init ();
|
||||
|
||||
argp = NULL;
|
||||
make_envp();
|
||||
make_envp (supress_ld_env);
|
||||
make_argp(a);
|
||||
}
|
||||
|
||||
SystemExec::SystemExec (std::string c, char **a)
|
||||
SystemExec::SystemExec (std::string c, char **a, bool supress_ld_env)
|
||||
: cmd(c) , argp(a)
|
||||
{
|
||||
init ();
|
||||
|
@ -97,10 +97,10 @@ SystemExec::SystemExec (std::string c, char **a)
|
|||
#ifdef PLATFORM_WINDOWS
|
||||
make_wargs(a);
|
||||
#endif
|
||||
make_envp();
|
||||
make_envp (supress_ld_env);
|
||||
}
|
||||
|
||||
SystemExec::SystemExec (std::string command, const std::map<char, std::string> subs)
|
||||
SystemExec::SystemExec (std::string command, const std::map<char, std::string> subs, bool supress_ld_env)
|
||||
{
|
||||
init ();
|
||||
make_argp_escaped(command, subs);
|
||||
|
@ -141,7 +141,7 @@ SystemExec::SystemExec (std::string command, const std::map<char, std::string> s
|
|||
// Glib::find_program_in_path () is only available in Glib >= 2.28
|
||||
// cmd = Glib::find_program_in_path (argp[0]);
|
||||
#endif
|
||||
make_envp();
|
||||
make_envp (supress_ld_env);
|
||||
}
|
||||
|
||||
char*
|
||||
|
@ -364,7 +364,7 @@ CALLBACK my_terminateApp(HWND hwnd, LPARAM procId)
|
|||
/* PROCESS API */
|
||||
|
||||
void
|
||||
SystemExec::make_envp()
|
||||
SystemExec::make_envp (bool)
|
||||
{
|
||||
; /* environemt is copied over with CreateProcess(...,env=0 ,..) */
|
||||
}
|
||||
|
@ -594,12 +594,17 @@ SystemExec::write_to_stdin (const void* data, size_t bytes)
|
|||
extern char **environ;
|
||||
|
||||
void
|
||||
SystemExec::make_envp()
|
||||
SystemExec::make_envp (bool supress_ld_env)
|
||||
{
|
||||
int i = 0;
|
||||
envp = (char **) calloc(1, sizeof(char*));
|
||||
/* copy current environment */
|
||||
for (i = 0; environ[i]; ++i) {
|
||||
#ifndef __APPLE__
|
||||
if (supress_ld_env && 0 == strncmp (environ[i], "LD_LIBRARY_PATH=", 17)) {
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
envp[i] = strdup(environ[i]);
|
||||
envp = (char **) realloc(envp, (i+2) * sizeof(char*));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue