X-Git-Url: http://git.kpe.io/?p=kmrcl.git;a=blobdiff_plain;f=os.lisp;h=805b10c3c5275baa529601ad4350c2e37a55c38c;hp=5bbfbfa4f2fbca3ff430e88dd14c9a10df46133b;hb=4298b0107c7d773ad7e2ee3b0837f8927da41578;hpb=1b7f506ec98bd5b885203a3250c52603b943cee9 diff --git a/os.lisp b/os.lisp index 5bbfbfa..805b10c 100644 --- a/os.lisp +++ b/os.lisp @@ -153,8 +153,27 @@ returns (VALUES output-string pid)" (error "Directory ~A does not exist [delete-directory-and-files]." dir)))) (defun file-size (file) - #+allegro (let ((stat (excl.osi:stat (namestring file)))) - (excl.osi:stat-size stat)) - #-allegro - (with-open-file (in file :direction :input) - (file-length in))) + (when (probe-file file) + #+allegro (let ((stat (excl.osi:stat (namestring file)))) + (excl.osi:stat-size stat)) + #-allegro + (with-open-file (in file :direction :input) + (file-length in)))) + +(defun getpid () + "Return the PID of the lisp process." + #+allegro (excl::getpid) + #+(and lispworks win32) (win32:get-current-process-id) + #+(and lispworks (not win32)) (system::getpid) + #+sbcl (sb-posix:getpid) + #+cmu (unix:unix-getpid) + #+openmcl (ccl::getpid) + #+(and clisp unix) (system::program-id) + #+(and clisp win32) (cond ((find-package :win32) + (funcall (find-symbol "GetCurrentProcessId" + :win32))) + (t + (system::getenv "PID"))) + ) + +