This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug translator/1341] respect TMPDIR


------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]