Processes spawned by taskset not respecting environment variables
Posted
by
jonesy16
on Server Fault
See other posts from Server Fault
or by jonesy16
Published on 2013-08-02T14:00:09Z
Indexed on
2013/08/02
15:41 UTC
Read the original article
Hit count: 253
linux
|environment-variables
I've run into an issue where an intel compiler generated program that I'm running with taskset has been putting its temporary files into the working directory instead of /tmp (defined by environment variable TMPDIR). If run by itself, it works correctly. If run with taskset (e.g.
taskset -c 0 <program>
Then it seems to completely ignore the TMPDIR environment variable. I then verified this by writing a quick bash script as follows:
contents of test.sh:
#!/bin/bash
echo $TMPDIR
When run by itself:
$ export TMPDIR=/tmp
$ test.sh
/tmp
When run through taskset:
$ export TMPDIR=/tmp
$ taskset -c 1 test.sh
""
Another test. If I export the TMPDIR variable inside of my script and then use taskset to spawn a new process, it doesn't know about that variable:
#!/bin/bash
export TMPDIR=/tmp
taskset -c 1 sh -c export
When run, the list of exported variables does not include TMPDIR. It works correctly with any other exported environment variable. If i diff the output of:
export
and
taskset -c 1 bash -c export
Then I see that there are 4 changes. The taskset spawned export doesn't have LD_LIBRARY_PATH, NLSPATH (intel compiler variable), SHLVL is 3 instead of 1, and TMPDIR is missing. Can anyone tell me why?
© Server Fault or respective owner