r10470: rename to numbers-within-percentage
[kmrcl.git] / os.lisp
diff --git a/os.lisp b/os.lisp
index 5b6fff3aa3d90aad02dd8ce57fa88f25c0560f87..805b10c3c5275baa529601ad4350c2e37a55c38c 100644 (file)
--- a/os.lisp
+++ b/os.lisp
@@ -60,7 +60,8 @@ returns (VALUES string-output error-output exit-status)"
          (let ((status 
                 (system:call-system-showing-output
                  command
-                 :shell-type "/bin/sh"
+                 :prefix ""
+                 :show-cmd nil
                  :output-stream output)))
            (values (get-output-stream-string output) nil status))
        (close output)))
@@ -119,7 +120,9 @@ returns (VALUES output-string pid)"
     (system:call-system-showing-output
      command
      :shell-type "/bin/sh"
-     :output-stream output)
+     :show-cmd nil
+     :prefix ""
+     :output-stream nil)
     
     #+clisp            ;XXX not exactly *verbose-out*, I know
     (ext:run-shell-command  command :output :terminal :wait t)
@@ -148,3 +151,29 @@ returns (VALUES output-string pid)"
                      (command-output cmd)))
                   ((eq if-does-not-exist :error)
                    (error "Directory ~A does not exist [delete-directory-and-files]." dir))))
+
+(defun file-size (file)
+  (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")))
+  )
+
+