[slime-devel] Patch for ABCL GETPID implementation

Mark Evenson mark.evenson at gmx.at
Wed Jan 23 06:18:04 EST 2008


Apparently PPID for the parent process id is not a standard feature of 
the Bourne shell (or at least it isn't present under solaris-5.11).

Attached is a patch to my ABCL GETPID implementation that uses 
HANDLER-CASE to return '0' if any error is raised in attempting to 
getpid().


-- 
<Mark.Evenson at gmx.at>

"[T]his is not a disentanglement from, but a progressive knotting into."

-------------- next part --------------
diff -r 0c36088c65c0 swank-abcl.lisp
--- a/swank-abcl.lisp	Wed Jan 02 17:02:52 2008 +0100
+++ b/swank-abcl.lisp	Wed Jan 23 12:09:39 2008 +0100
@@ -143,8 +143,7 @@
   (funcall fn))
 
 (defimplementation getpid ()
-  (if (not (find :unix *features*))
-      0
+  (handler-case 
       (let* ((runtime 
               (java:jstatic "getRuntime" "java.lang.Runtime"))
              (command
@@ -153,8 +152,8 @@
              (runtime-exec-jmethod 		
               ;; Complicated because java.lang.Runtime.exec() is
               ;; overloaded on a non-primitive type (array of
-              ;; java.lang.String), so we have to use the actual parameter
-              ;; instance to get java.lang.Class
+              ;; java.lang.String), so we have to use the actual
+              ;; parameter instance to get java.lang.Class
               (java:jmethod "java.lang.Runtime" "exec" 
                             (java:jcall 
                              (java:jmethod "java.lang.Object" "getClass")
@@ -162,19 +161,19 @@
              (process 
               (java:jcall runtime-exec-jmethod runtime command))
              (output 
-              (java:jcall (java:jmethod "java.lang.Process" "getInputStream") 
+              (java:jcall (java:jmethod "java.lang.Process" "getInputStream")
                           process)))
-        (java:jcall (java:jmethod "java.lang.Process" "waitFor") process)
-        (loop 
-         :with b
-         :do (setq b 
-                   (java:jcall (java:jmethod "java.io.InputStream" "read")
-                               output))
-         :until (member b '(-1 #x0a))	; Either EOF or LF
-         :collecting (code-char b) :into result
-         :finally (return 
-                    (values 
-                     (parse-integer (coerce result 'string))))))))
+         (java:jcall (java:jmethod "java.lang.Process" "waitFor")
+                     process)
+	 (loop :with b :do 
+	    (setq b 
+		  (java:jcall (java:jmethod "java.io.InputStream" "read")
+			      output))
+	    :until (member b '(-1 #x0a))	; Either EOF or LF
+	    :collecting (code-char b) :into result
+	    :finally (return 
+		       (parse-integer (coerce result 'string)))))
+    (t () 0))) 
 
 (defimplementation lisp-implementation-type-name ()
   "armedbear")


More information about the slime-devel mailing list