From 43c193e2c20ce746c6c4d23d25ceba4d192c7d15 Mon Sep 17 00:00:00 2001 From: Stas Boukarev Date: Tue, 22 May 2012 22:39:07 +0400 Subject: [PATCH] run-program: Don't use /tmp unconditionally. * Use TEMP on win32 and TMPDIR on non-win32. * Don't delete just opened temporary files on windows, because opened files cannot be unlinked on windows. Fixes lp#968837. --- NEWS | 2 ++ src/code/run-program.lisp | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index c4c6ce0..8833fe0 100644 --- a/NEWS +++ b/NEWS @@ -15,6 +15,8 @@ changes relative to sbcl-1.0.57: * bug fix: ENSURE-GENERIC-METHOD-COMBINATION accepts method combination objects as its :METHOD-COMBINATION argument, not just lists designating method combinations. (lp#936513) + * bug fix: run-program no longer unconditionally uses /tmp/ for temporary files. + (lp#968837). changes in sbcl-1.0.57 relative to sbcl-1.0.56: * RANDOM enhancements and bug fixes: diff --git a/src/code/run-program.lisp b/src/code/run-program.lisp index d9e00f2..3cc2e85 100644 --- a/src/code/run-program.lisp +++ b/src/code/run-program.lisp @@ -939,6 +939,12 @@ Users Manual for details about the PROCESS structure."#-win32" (get-stream-fd-and-external-format (two-way-stream-output-stream stream) direction)))))) +(defun get-temporary-directory () + #-win32 (or (sb-ext:posix-getenv "TMPDIR") + "/tmp") + #+win32 (or (sb-ext:posix-getenv "TEMP") + "C:/Temp")) + ;;; Find a file descriptor to use for object given the direction. ;;; Returns the descriptor. If object is :STREAM, returns the created @@ -957,10 +963,14 @@ Users Manual for details about the PROCESS structure."#-win32" ;; run afoul of disk quotas or to choke on small /tmp file systems. (flet ((make-temp-fd () (multiple-value-bind (fd name/errno) - (sb-unix:sb-mkstemp "/tmp/.run-program-XXXXXX" #o0600) + (sb-unix:sb-mkstemp (format nil "~a/.run-program-XXXXXX" + (get-temporary-directory)) + #o0600) (unless fd (error "could not open a temporary file: ~A" (strerror name/errno))) + ;; Can't unlink an opened file on Windows + #-win32 (unless (sb-unix:unix-unlink name/errno) (sb-unix:unix-close fd) (error "failed to unlink ~A" name/errno)) -- 1.7.10.4