From ea8ea02c7c1c7e3bfc97a580ab4ea0649f81641b Mon Sep 17 00:00:00 2001 From: fche Date: Tue, 18 Apr 2006 11:21:04 +0000 Subject: 2006-04-18 Eugene Teo PR 1341 * main.cxx (main): Use TMPDIR instead of hard-coded /tmp. --- main.cxx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'main.cxx') diff --git a/main.cxx b/main.cxx index 437ff722..8005a7ec 100644 --- a/main.cxx +++ b/main.cxx @@ -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; -- cgit