1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-25 04:40:19 +02:00

build: Build and check (ice-9 popen) only when --enable-posix and HAVE_FORK.

Fixes <http://bugs.gnu.org/13848>.
Reported by Jan Schukat <shookie@email.de>.

* configure.ac: Rename `HAVE_FORK' conditional to `BUILD_ICE_9_POPEN'.
  Set it when both $enable_posix and $ac_cv_func_fork are true.
* libguile/posix.c (scm_init_posix): Add the `fork' feature.
* doc/ref/api-options.texi (Common Feature Symbols): Add `fork'.
* doc/ref/posix.texi (Pipes): Add footnote mentioning the `fork'
  feature.
* module/Makefile.am (SCRIPTS_SOURCES): Make `scripts/autofrisk.scm' and
  `scripts/scan-api.scm' conditional on `BUILD_ICE_9_POPEN'.
* test-suite/tests/popen.test (if-supported): New macro.
  Wrap body in `if-supported'.
This commit is contained in:
Ludovic Courtès 2013-03-29 19:04:56 +01:00
parent 7e7c6f6a93
commit df3d365a99
6 changed files with 188 additions and 176 deletions

View file

@ -761,7 +761,8 @@ AC_CHECK_FUNCS([DINFINITY DQNAN cexp chsize clog clog10 ctermid \
strcoll strcoll_l newlocale utimensat sched_getaffinity \ strcoll strcoll_l newlocale utimensat sched_getaffinity \
sched_setaffinity sendfile]) sched_setaffinity sendfile])
AM_CONDITIONAL([HAVE_FORK], [test "x$ac_cv_func_fork" = "xyes"]) AM_CONDITIONAL([BUILD_ICE_9_POPEN],
[test "x$enable_posix" = "xyes" && test "x$ac_cv_func_fork" = "xyes"])
# Reasons for testing: # Reasons for testing:
# netdb.h - not in mingw # netdb.h - not in mingw

View file

@ -1,6 +1,7 @@
@c -*-texinfo-*- @c -*-texinfo-*-
@c This is part of the GNU Guile Reference Manual. @c This is part of the GNU Guile Reference Manual.
@c Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2011, 2012 @c Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
@c 2008, 2009, 2010, 2011, 2012, 2013
@c Free Software Foundation, Inc. @c Free Software Foundation, Inc.
@c See the file guile.texi for copying conditions. @c See the file guile.texi for copying conditions.
@ -281,6 +282,11 @@ Databases}).
Indicates support for POSIX functions: @code{pipe}, @code{getgroups}, Indicates support for POSIX functions: @code{pipe}, @code{getgroups},
@code{kill}, @code{execl} and so on (@pxref{POSIX}). @code{kill}, @code{execl} and so on (@pxref{POSIX}).
@item fork
Indicates support for the POSIX @code{fork} function (@pxref{Processes,
@code{primitive-fork}}). This is a prerequisite for the @code{(ice-9
popen)} module (@pxref{Pipes}).
@item random @item random
Indicates availability of random number generation functions: Indicates availability of random number generation functions:
@code{random}, @code{copy-random-state}, @code{random-uniform} and so on @code{random}, @code{copy-random-state}, @code{random-uniform} and so on

View file

@ -2188,7 +2188,8 @@ controlling terminal. The return value is unspecified.
The following procedures are similar to the @code{popen} and The following procedures are similar to the @code{popen} and
@code{pclose} system routines. The code is in a separate ``popen'' @code{pclose} system routines. The code is in a separate ``popen''
module: module@footnote{This module is only available on systems where the
@code{fork} feature is provided (@pxref{Common Feature Symbols}).}:
@lisp @lisp
(use-modules (ice-9 popen)) (use-modules (ice-9 popen))

View file

@ -2336,6 +2336,7 @@ scm_init_posix ()
#include "libguile/posix.x" #include "libguile/posix.x"
#ifdef HAVE_FORK #ifdef HAVE_FORK
scm_add_feature ("fork");
scm_c_register_extension ("libguile-" SCM_EFFECTIVE_VERSION, scm_c_register_extension ("libguile-" SCM_EFFECTIVE_VERSION,
"scm_init_popen", "scm_init_popen",
(scm_t_extension_init_func) scm_init_popen, (scm_t_extension_init_func) scm_init_popen,

View file

@ -159,7 +159,6 @@ BRAINFUCK_LANG_SOURCES = \
language/brainfuck/spec.scm language/brainfuck/spec.scm
SCRIPTS_SOURCES = \ SCRIPTS_SOURCES = \
scripts/autofrisk.scm \
scripts/compile.scm \ scripts/compile.scm \
scripts/disassemble.scm \ scripts/disassemble.scm \
scripts/display-commentary.scm \ scripts/display-commentary.scm \
@ -175,7 +174,6 @@ SCRIPTS_SOURCES = \
scripts/use2dot.scm \ scripts/use2dot.scm \
scripts/snarf-check-and-output-texi.scm \ scripts/snarf-check-and-output-texi.scm \
scripts/summarize-guile-TODO.scm \ scripts/summarize-guile-TODO.scm \
scripts/scan-api.scm \
scripts/api-diff.scm \ scripts/api-diff.scm \
scripts/read-rfc822.scm \ scripts/read-rfc822.scm \
scripts/snarf-guile-m4-docs.scm scripts/snarf-guile-m4-docs.scm
@ -252,12 +250,17 @@ ICE_9_SOURCES = \
ice-9/serialize.scm \ ice-9/serialize.scm \
ice-9/local-eval.scm ice-9/local-eval.scm
if HAVE_FORK if BUILD_ICE_9_POPEN
# This functionality is missing on systems without `fork'---i.e., Windows. # This functionality is missing on systems without `fork'---i.e., Windows.
ICE_9_SOURCES += ice-9/popen.scm ICE_9_SOURCES += ice-9/popen.scm
endif HAVE_FORK # These modules rely on (ice-9 popen).
SCRIPTS_SOURCES += \
scripts/autofrisk.scm \
scripts/scan-api.scm
endif BUILD_ICE_9_POPEN
SRFI_SOURCES = \ SRFI_SOURCES = \
srfi/srfi-2.scm \ srfi/srfi-2.scm \

View file

@ -1,6 +1,6 @@
;;;; popen.test --- exercise ice-9/popen.scm -*- scheme -*- ;;;; popen.test --- exercise ice-9/popen.scm -*- scheme -*-
;;;; ;;;;
;;;; Copyright 2003, 2006, 2010, 2011 Free Software Foundation, Inc. ;;;; Copyright 2003, 2006, 2010, 2011, 2013 Free Software Foundation, Inc.
;;;; ;;;;
;;;; This library is free software; you can redistribute it and/or ;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public ;;;; modify it under the terms of the GNU Lesser General Public
@ -17,9 +17,7 @@
;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
(define-module (test-suite test-ice-9-popen) (define-module (test-suite test-ice-9-popen)
#:use-module (test-suite lib) #:use-module (test-suite lib))
#:use-module (ice-9 popen))
;; read from PORT until eof is reached, return what's read as a string ;; read from PORT until eof is reached, return what's read as a string
(define (read-string-to-eof port) (define (read-string-to-eof port)
@ -37,12 +35,19 @@
thunk thunk
restore-signals)) restore-signals))
(define-syntax-rule (if-supported body ...)
(if (provided? 'fork)
(begin body ...)))
;; (if-supported
;; open-input-pipe (use-modules (ice-9 popen))
;;
(with-test-prefix "open-input-pipe"
;;
;; open-input-pipe
;;
(with-test-prefix "open-input-pipe"
(pass-if-exception "no args" exception:wrong-num-args (pass-if-exception "no args" exception:wrong-num-args
(open-input-pipe)) (open-input-pipe))
@ -110,15 +115,13 @@
(display "hello!\n" (cdr p2c)) (display "hello!\n" (cdr p2c))
(force-output (cdr p2c)) (force-output (cdr p2c))
(close-pipe port) (close-pipe port)
result))) result))))
) ;;
;; open-output-pipe
;;
;; (with-test-prefix "open-output-pipe"
;; open-output-pipe
;;
(with-test-prefix "open-output-pipe"
(pass-if-exception "no args" exception:wrong-num-args (pass-if-exception "no args" exception:wrong-num-args
(open-output-pipe)) (open-output-pipe))
@ -187,15 +190,13 @@
;; the child a broken pipe and so allow it to exit. ;; the child a broken pipe and so allow it to exit.
(close-port (car c2p)) (close-port (car c2p))
(close-pipe port) (close-pipe port)
result))))) result))))))
) ;;
;; close-pipe
;;
;; (with-test-prefix "close-pipe"
;; close-pipe
;;
(with-test-prefix "close-pipe"
(pass-if-exception "no args" exception:wrong-num-args (pass-if-exception "no args" exception:wrong-num-args
(close-pipe)) (close-pipe))
@ -208,5 +209,4 @@
(pass-if "exit 1" (pass-if "exit 1"
(let ((st (close-pipe (open-output-pipe "exit 1")))) (let ((st (close-pipe (open-output-pipe "exit 1"))))
(and (status:exit-val st) (and (status:exit-val st)
(= 1 (status:exit-val st)))))) (= 1 (status:exit-val st)))))))