Changeset 9854


Ignore:
Timestamp:
Jun 30, 2008, 5:00:02 PM (11 years ago)
Author:
gb
Message:

Define the SERIOUS-CONDITION EXTERNAL-PROCESS-CREATION-FAILURE.

Add *SILENTLY-IGNORE-CATASTROPHIC-FAILURE-IN-RUN-PROGRAM, initialize
it to T on this branch.

Add :SILENTLY-IGNORE-CATASTROPHIC-FAILURE arg to RUN-PROGRAM. When
true, an EXTERNAL-PROCESS with status :ERROR and some exit code
(and a null PID) is returned, as if that was a reasonable thing
to do. If catastrophic failure (#_fork error) isn't silently
ignored, a serious condition of type EXTERNAL-PROCESS-CREATION-FAILURE
is signaled.

Make things that expect EXTERNAL-PROCESS-PID to be non-NIL handle
the possibilit that catastrophic falures have been ignored.

Location:
branches/working-0711/ccl/level-1
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/working-0711/ccl/level-1/l1-error-system.lisp

    r9578 r9854  
    491491                  (apply #'format stream (simple-condition-format-control c)
    492492                         (simple-condition-format-arguments c)))))
     493
     494(define-condition external-process-creation-failure (serious-condition)
     495  ((proc :initarg :proc))
     496  (:report (lambda (c stream)
     497             (with-slots (proc) c
     498               (let* ((code (external-process-%exit-code proc)))
     499                 (format stream "Fork failed in ~s: ~a. " proc (if (eql code -1) "random lisp error" (%strerror code))))))))
     500   
    493501                         
    494502(defun restartp (thing)
  • branches/working-0711/ccl/level-1/linux-files.lisp

    r9850 r9854  
    883883                   (remove-external-process p)
    884884                   (setq terminated t)))))))))
    885      
     885
     886
    886887(defun run-external-process (proc in-fd out-fd error-fd argv &optional env)
    887888  (let* ((signaled nil))
     
    915916        (signal-semaphore (external-process-signal proc))))))
    916917
    917                
     918(defparameter *silently-ignore-catastrophic-failure-in-run-program*
     919  #+ccl-0711 t #-ccl-0711 nil)
     920
    918921(defun run-program (program args &key
    919922                            (wait t) pty
     
    922925                            (error :output) (if-error-exists :error)
    923926                            status-hook (element-type 'character)
    924                             env)
     927                            env
     928                            (silently-ignore-catastrophic-failures
     929                             *silently-ignore-catastrophic-failure-in-run-program*))
    925930  "Invoke an external program as an OS subprocess of lisp."
    926931  (declare (ignore pty))
     
    986991            (wait-on-semaphore (external-process-completed proc))))
    987992      (if (eq (external-process-%status proc) :error)
    988         (error "Fork failed in ~s: ~s" proc (%strerror (external-process-%exit-code proc))))
    989       (and (external-process-pid proc)
    990            proc)))
     993        (if silently-ignore-catastrophic-failures
     994          proc
     995          (error 'external-process-creation-failure proc))
     996        (and (external-process-pid proc)
     997             proc))))
    991998
    992999
     
    10711078  "Send the specified signal to the specified external process.  (Typically,
    10721079it would only be useful to call this function if the EXTERNAL-PROCESS was
    1073 created with :WAIT NIL.) Return T if successful; signal an error otherwise."
     1080created with :WAIT NIL.) Return T if successful, NIL if the process wasn't
     1081created successfully, and signal an error otherwise."
    10741082  (require-type proc 'external-process)
    1075   (let* ((pid (external-process-pid proc))
    1076          (error (syscall syscalls::kill pid signal)))
    1077     (or (eql error 0)
    1078         (%errno-disp error))))
     1083  (let* ((pid (external-process-pid proc)))
     1084    (when pid
     1085      (let* ((error (syscall syscalls::kill pid signal)))
     1086        (or (eql error 0)
     1087            (%errno-disp error))))))
    10791088
    10801089;;; EOF on a TTY is transient, but I'm less sure of other cases.
Note: See TracChangeset for help on using the changeset viewer.