rc

[fork] interactive rc shell
Log | Files | Refs | README | LICENSE

commit a8c039e14eafd7933776e8616715955d52320600
parent a3d14284af40b0d4d9bf33cf33f640c3ea6102ad
Author: tgoodwin <tgoodwin>
Date:   Tue, 24 Feb 1998 12:00:28 +0000

try for mkfifo()

Diffstat:
Mconfigure.ac | 12+++++++++---
Mglom.c | 11+++++++++--
2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/configure.ac b/configure.ac @@ -196,8 +196,9 @@ esac AM_CONDITIONAL(N_H_B, test "$ac_cv_sys_interpreter" = no) -dnl What do we do for command arguments? We want /dev/fd, Linux's -dnl /proc/self/fd, or failing that, FIFOs. +dnl What do we do for command arguments? We want /dev/fd or Linux's +dnl /proc/self/fd. Failing that, we'll try for POSIX mkfifo(), or a +dnl mknod() that makes FIFOs. AC_CACHE_CHECK(for /dev/fd, rc_cv_sys_dev_fd, if test -d /dev/fd && test -r /dev/fd/0; then rc_cv_sys_dev_fd=yes @@ -210,7 +211,12 @@ AC_CACHE_CHECK(for /dev/fd, rc_cv_sys_dev_fd, case "$rc_cv_sys_dev_fd" in yes) AC_DEFINE(HAVE_DEV_FD) ;; odd) AC_DEFINE(HAVE_PROC_SELF_FD) ;; -no) AC_CACHE_CHECK(for named pipes, rc_cv_sys_fifo, +no) AC_CHECK_FUNCS(mkfifo) ;; +esac + +case "$ac_cv_func_mkfifo" in +yes) AC_DEFINE(HAVE_FIFO) ;; +no) AC_CACHE_CHECK(for mknod FIFOs, rc_cv_sys_fifo, AC_TRY_RUN([ #include <sys/types.h> #include <sys/stat.h> diff --git a/glom.c b/glom.c @@ -324,6 +324,12 @@ static List *mkcmdarg(Node *n) { #elif HAVE_FIFO +#if HAVE_MKFIFO +/* Have POSIX mkfifo(). */ +#else +#define mkfifo(n,m) mknod(n, S_IFIFO | m, 0) +#endif + static List *mkcmdarg(Node *n) { int fd; char *name; @@ -331,8 +337,9 @@ static List *mkcmdarg(Node *n) { Estack *e = enew(Estack); List *ret = nnew(List); static int fifonumber = 0; + name = nprint("/tmp/rc%d.%d", getpid(), fifonumber++); - if (mknod(name, S_IFIFO | 0666, 0) < 0) { + if (mkfifo(name, 0666) < 0) { uerror("mknod"); return NULL; } @@ -360,7 +367,7 @@ static List *mkcmdarg(Node *n) { #else static List *mkcmdarg(Node *n) { - rc_error("named pipes are not supported"); + rc_error("command arguments are not supported"); return NULL; }