src/hg/utils/automation/SafePipe.pm 1.5

1.5 2009/03/10 19:27:47 larrym
change exec to handle cases where /data/tmp doesn't exist
Index: src/hg/utils/automation/SafePipe.pm
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/utils/automation/SafePipe.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -b -B -U 4 -r1.4 -r1.5
--- src/hg/utils/automation/SafePipe.pm	10 Mar 2009 18:35:37 -0000	1.4
+++ src/hg/utils/automation/SafePipe.pm	10 Mar 2009 19:27:47 -0000	1.5
@@ -67,17 +67,21 @@
     my ($obj) = @_;
 
     my $stderrCreated = 0;
     my $stderrFile = $obj->{STDERR};
+    my $tmpDir = $ENV{TMPDIR} || "/data/tmp";
+    if(!(defined($tmpDir) && -d $tmpDir)) {
+        $tmpDir = "/tmp";
+    }
     if(!(defined($stderrFile))) {
-        $stderrFile = "/data/tmp/SafePipe$$.err";
+        $stderrFile = "$tmpDir/SafePipe$$.err";
         $stderrCreated = 1;
         unlink($stderrFile);
     }
     my $stdoutCreated = 0;
     my $stdoutFile = $obj->{STDOUT};
     if(!(defined($stdoutFile))) {
-        $stdoutFile = "/data/tmp/SafePipe$$.out";
+        $stdoutFile = "$tmpDir/SafePipe$$.out";
         $stdoutCreated = 1;
         unlink($stdoutFile);
     }