diff options
author | fche <fche> | 2006-04-18 11:21:04 +0000 |
---|---|---|
committer | fche <fche> | 2006-04-18 11:21:04 +0000 |
commit | ea8ea02c7c1c7e3bfc97a580ab4ea0649f81641b (patch) | |
tree | 36a38d3e43b1ab9a7a81f5bf8e99ac96b047cbbf /main.cxx | |
parent | 4a5e8a70d3263060375fee5e98ab9c2f386ae9c2 (diff) | |
download | systemtap-steved-ea8ea02c7c1c7e3bfc97a580ab4ea0649f81641b.tar.gz systemtap-steved-ea8ea02c7c1c7e3bfc97a580ab4ea0649f81641b.tar.xz systemtap-steved-ea8ea02c7c1c7e3bfc97a580ab4ea0649f81641b.zip |
2006-04-18 Eugene Teo <eteo@redhat.com>
PR 1341
* main.cxx (main): Use TMPDIR instead of hard-coded /tmp.
Diffstat (limited to 'main.cxx')
-rw-r--r-- | main.cxx | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -275,14 +275,18 @@ main (int argc, char * const argv []) // Create a temporary directory to build within. // Be careful with this, as "s.tmpdir" is "rm -rf"'d at the end. { - char tmpdirt[] = "/tmp/stapXXXXXX"; - const char* tmpdir = mkdtemp (tmpdirt); + char* tmpdir_env = getenv("TMPDIR"); + if (! tmpdir_env) + tmpdir_env = "/tmp"; + + string stapdir = "/stapXXXXXX"; + string tmpdirt = tmpdir_env + stapdir; + const char* tmpdir = mkdtemp((char *)tmpdirt.c_str()); if (! tmpdir) { const char* e = strerror (errno); - cerr << "mkdtemp (\"" << tmpdir << "\"): " << e << endl; - s.tmpdir = ""; - rc = 1; + cerr << "ERROR: cannot create temporary directory (\"" << tmpdirt << "\"): " << e << endl; + exit (1); // die } else s.tmpdir = tmpdir; |