This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
[Bug translator/1341] respect TMPDIR
- From: Eugene Teo <eteo at redhat dot com>
- To: systemtap at sources dot redhat dot com
- Date: Tue, 18 Apr 2006 10:39:55 +0800
- Subject: [Bug translator/1341] respect TMPDIR
- Organization: Red Hat Asia Pacific
- References: <20050913212617.1341.fche@redhat.com> <20060418023644.31221.qmail@sourceware.org>
------- Additional Comments From eteo at redhat dot com 2006-04-18
02:36 -------
(In reply to comment #0)
>It may be nice not to hard-code /tmp as the place under which the temporary
>directory is created.
The following patch uses the TMPDIR environment variable to define
the place under which the temporary directory will be created. If it
is not defined, /tmp will be used instead.
ChangeLog | 4 ++++
main.cxx | 11 ++++++++---
2 files changed, 12 insertions(+), 3 deletions(-)
diff -Naurp src.default/ChangeLog src/ChangeLog
--- src.default/ChangeLog 2006-04-18 04:32:18.000000000 +0800
+++ src/ChangeLog 2006-04-18 10:16:10.000000000 +0800
@@ -1,3 +1,7 @@
+2006-04-18 Eugene Teo <eteo@redhat.com>
+ PR 1341
+ * main.cxx (main): Use TMPDIR instead of hard-coded /tmp.
+
2006-04-17 Frank Ch. Eigler <fche@elastic.org>
* tapsets.cxx (mark_derived_probe::emit_{de}registrations):
diff -Naurp src.default/main.cxx src/main.cxx
--- src.default/main.cxx 2006-04-05 13:20:08.000000000 +0800
+++ src/main.cxx 2006-04-18 10:07:11.000000000 +0800
@@ -275,12 +275,17 @@ 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;
+ cerr << "mkdtemp (\"" << tmpdirt.c_str() << "\"): " << e << endl;
s.tmpdir = "";
rc = 1;
}
--
eteo redhat.com ph: +65 6490 4142 http://www.kernel.org/~eugeneteo
gpg fingerprint: 47B9 90F6 AE4A 9C51 37E0 D6E1 EA84 C6A2 58DF 8823