0

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?

1
  • Sorry, I guess it doesn't go without saying that TMPDIR is set in my environment but it is. It's been exported with export TMPDIR=/tmp
    – jonesy16
    Aug 2, 2013 at 15:09

1 Answer 1

0

I don't actually see evidence here that $TMPDIR is set in your environment. I can replicate the behavior you describe if I set TMPDIR as a local shell variable, like this:

$ TMPDIR=/tmp
$ taskset -c 0 sh -c 'echo TMPDIR: $TMPDIR'

Which yields:

TMPDIR:

But if I export TMPDIR to the environment, it works as one would expect:

$ TMPDIR=/tmp
$ export TMPDIR
$ taskset -c 0 sh -c 'echo TMPDIR: $TMPDIR'
TMPDIR: /tmp

Are you certain that TMPDIR is set in your environment? You can use the env command to dump your current environment:

$ env | grep TMPDIR
TMPDIR=/tmp

If I take your updated script:

#!/bin/bash
export TMPDIR=/tmp
taskset -c 1 sh -c export

And run this on my CentOS system:

$ sh taskset.sh  | grep TMPDIR
export TMPDIR="/tmp"

It works as advertised. I'm not sure what's going on in your environment.

3
  • I tried your commands on my system (CENTOS 6.3) and I get TMPDIR: as the response.
    – jonesy16
    Aug 2, 2013 at 15:17
  • I'm running these commands on a CentOS 6.4 system.
    – larsks
    Aug 2, 2013 at 15:18
  • Well then I'm more confused than ever .... It does seem to work correctly with any other variable name, just not TMPDIR.
    – jonesy16
    Aug 2, 2013 at 15:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .