Changeset 7308


Ignore:
Timestamp:
Sep 26, 2007, 7:14:02 PM (12 years ago)
Author:
wws
Message:

run-program and run-external-process take an additional "env" parameter,
a list of pairs. For each pair the environment variable (string (car pair)) is set
to (cdr pair) in the external program's environment before it is exec'd.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ccl/level-1/linux-files.lisp

    r7265 r7308  
    839839                   (setq terminated t)))))))))
    840840     
    841 (defun run-external-process (proc in-fd out-fd error-fd)
     841(defun run-external-process (proc in-fd out-fd error-fd &optional env)
     842  ;; type-check the env variable
     843  (dolist (pair env)
     844    (destructuring-bind (var . val) pair
     845      (assert (typep var '(or string symbol character)))
     846      (assert (typep val 'string))))
    842847  (call-with-string-vector
    843848   #'(lambda (argv)
     
    846851         (cond ((zerop child-pid)
    847852                ;; Running in the child; do an exec
     853                (dolist (pair env)
     854                  (setenv (string (car pair)) (cdr pair)))
    848855                (without-interrupts
    849856                 (exec-with-io-redirection
     
    863870                            output (if-output-exists :error)
    864871                            (error :output) (if-error-exists :error)
    865                             status-hook (element-type 'character))
     872                            status-hook (element-type 'character)
     873                            env)
    866874  "Invoke an external program as an OS subprocess of lisp."
    867875  (declare (ignore pty))
     
    912920            (format nil "Monitor thread for external process ~a" args)
    913921                   
    914             #'run-external-process proc in-fd out-fd error-fd)
     922            #'run-external-process proc in-fd out-fd error-fd env)
    915923           (wait-on-semaphore (external-process-signal proc))
    916924           )
Note: See TracChangeset for help on using the changeset viewer.