* [Bug translator/1341] respect TMPDIR
[not found] ` <20060418023644.31221.qmail@sourceware.org>
@ 2006-04-18 2:40 ` Eugene Teo
0 siblings, 0 replies; only message in thread
From: Eugene Teo @ 2006-04-18 2:40 UTC (permalink / raw)
To: systemtap
------- 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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2006-04-18 2:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20050913212617.1341.fche@redhat.com>
[not found] ` <20060418023644.31221.qmail@sourceware.org>
2006-04-18 2:40 ` [Bug translator/1341] respect TMPDIR Eugene Teo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).