mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-17 09:10:22 +02:00
(open-process): Close input-fdes, output-fdes and
error-fdes after duping them to 0, 1 and 2.
This commit is contained in:
parent
0ed417f42b
commit
557b225f49
1 changed files with 14 additions and 7 deletions
|
@ -106,23 +106,30 @@
|
||||||
(= pt-fileno error-fdes)))
|
(= pt-fileno error-fdes)))
|
||||||
(close-fdes pt-fileno))))))
|
(close-fdes pt-fileno))))))
|
||||||
|
|
||||||
;; copy the three selected descriptors to the standard
|
;; Copy the three selected descriptors to the standard
|
||||||
;; descriptors 0, 1, 2. note that it's possible that
|
;; descriptors 0, 1, 2, if not already there
|
||||||
;; output-fdes or input-fdes is equal to error-fdes.
|
|
||||||
|
|
||||||
(cond ((not (= input-fdes 0))
|
(cond ((not (= input-fdes 0))
|
||||||
(if (= output-fdes 0)
|
(if (= output-fdes 0)
|
||||||
(set! output-fdes (dup->fdes 0)))
|
(set! output-fdes (dup->fdes 0)))
|
||||||
(if (= error-fdes 0)
|
(if (= error-fdes 0)
|
||||||
(set! error-fdes (dup->fdes 0)))
|
(set! error-fdes (dup->fdes 0)))
|
||||||
(dup2 input-fdes 0)))
|
(dup2 input-fdes 0)
|
||||||
|
;; it's possible input-fdes is error-fdes
|
||||||
|
(if (not (= input-fdes error-fdes))
|
||||||
|
(close-fdes input-fdes))))
|
||||||
|
|
||||||
(cond ((not (= output-fdes 1))
|
(cond ((not (= output-fdes 1))
|
||||||
(if (= error-fdes 1)
|
(if (= error-fdes 1)
|
||||||
(set! error-fdes (dup->fdes 1)))
|
(set! error-fdes (dup->fdes 1)))
|
||||||
(dup2 output-fdes 1)))
|
(dup2 output-fdes 1)
|
||||||
|
;; it's possible output-fdes is error-fdes
|
||||||
|
(if (not (= output-fdes error-fdes))
|
||||||
|
(close-fdes output-fdes))))
|
||||||
|
|
||||||
(dup2 error-fdes 2)
|
(cond ((not (= error-fdes 2))
|
||||||
|
(dup2 error-fdes 2)
|
||||||
|
(close-fdes error-fdes)))
|
||||||
|
|
||||||
(apply execlp prog prog args)))
|
(apply execlp prog prog args)))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue