commit 67fd3c37e6908795bd86220435a37637c9e16d63
parent 063d3cc3f65f8f5b8dd636b7b8bd07e132e5aa28
Author: tgoodwin <tgoodwin>
Date: Tue, 17 Feb 1998 15:46:42 +0000
first stab at getting execve.c only compiled when needed
Diffstat:
7 files changed, 22 insertions(+), 30 deletions(-)
diff --git a/Makefile.am b/Makefile.am
@@ -8,29 +8,20 @@ HISTBIN =
HISTMAN =
endif
-# Pick correct version of rdwr.c, depending on whether we have restartable
-# system calls or not.
-
-# Include execve.c only if kernel doesn't handle `#!' magic numbers.
-
if H_R_S
-if N_H_B
-OPT_SRC = execve.c rdwr-bsd.c
+RDWR = rdwr-bsd.c
else
-OPT_SRC = rdwr-bsd.c
+RDWR = rdwr.c
endif
-else
+
if N_H_B
-OPT_SRC = execve.c rdwr.c
-else
-OPT_SRC = rdwr.c
-endif
+EXECVE = execve.c
endif
bin_PROGRAMS = rc
noinst_PROGRAMS = $(HISTBIN)
-rc_SOURCES = @ADDON@ builtins.c except.c exec.c fn.c footobar.c getopt.c glob.c glom.c hash.c heredoc.c input.c lex.c list.c main.c match.c nalloc.c open.c print.c redir.c sigmsgs.c signal.c status.c tree.c utils.c var.c wait.c walk.c which.c y.tab.c $(OPT_SRC)
+rc_SOURCES = @ADDON@ builtins.c except.c exec.c fn.c footobar.c getopt.c glob.c glom.c hash.c heredoc.c input.c lex.c list.c main.c match.c nalloc.c open.c print.c redir.c sigmsgs.c signal.c status.c tree.c utils.c var.c wait.c walk.c which.c y.tab.c $(RDWR) $(EXECVE)
EXTRA_rc_SOURCES = execve.c rdwr.c rdwr-bsd.c
diff --git a/acconfig.h b/acconfig.h
@@ -4,6 +4,9 @@
/* Define to the default path used if $PATH is empty when rc starts. */
#undef DEFAULTPATH
+/* Define if your kernel has SysV special SIGCLD semantics. */
+#undef HAVE_SYSV_SIGCLD
+
/* Define if your kernel supports `#!' magic numbers. */
#undef HASH_BANG
diff --git a/configure.ac b/configure.ac
@@ -35,7 +35,7 @@ AC_CACHE_CHECK(for signal names, rc_cv_signal_h,
fi
done
)
-case "x$rc_cv_signal_h" in
+case "$rc_cv_signal_h" in
'') AC_MSG_ERROR(Can't find signal names in $rc_cv_full_signal_h) ;;
*) SIGNAL_H=$rc_cv_signal_h ;;
esac
@@ -170,12 +170,9 @@ esac
dnl Does the kernel handle `#! /interpreter'?
AC_SYS_INTERPRETER
case "$ac_cv_sys_interpreter" in
-yes) AC_DEFINE(HASH_BANG)
- EXECVE=''
- ;;
-no) EXECVE=execve.o ;;
+yes) AC_DEFINE(HASH_BANG) ;;
esac
-AC_SUBST(EXECVE)
+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
@@ -271,7 +268,7 @@ AC_ARG_ENABLE(history,
*) rc_history=no ;;
esac
], rc_history=no)
-AM_CONDITIONAL(HISTORY, test x$rc_history = xyes)
+AM_CONDITIONAL(HISTORY, test "$rc_history" = yes)
AC_ARG_WITH(addon, [ --with-addon Extra builtins, from addon.c ],[
case "$withval" in
diff --git a/exec.c b/exec.c
@@ -90,11 +90,7 @@ extern void exec(List *s, bool parent) {
return;
rc_exit(getstatus());
}
-#if HASH_BANG
- execve(path, (char * const *) av, (char * const *) ev);
-#else
- my_execve(path, av, ev); /* bogus, huh? */
-#endif
+ rc_execve(path, (char * const *) av, (char * const *) ev);
#ifdef DEFAULTINTERP
if (errno == ENOEXEC) {
@@ -103,6 +99,7 @@ extern void exec(List *s, bool parent) {
execve(*av, (char * const *) av, (char * const *) ev);
}
#endif
+
uerror(*av);
rc_exit(1);
/* NOTREACHED */
diff --git a/execve.c b/execve.c
@@ -1,8 +1,8 @@
/* execve.c: an execve() for geriatric unices without #! */
/*
- NOTE: this file depends on a hack in footobar.c which places two free spots before
- av[][] so that execve does not have to call malloc.
+ NOTE: this file depends on a hack in footobar.c which places two free
+ spots before av[][] so that execve does not have to call malloc.
*/
#include <errno.h>
@@ -10,7 +10,7 @@
#define giveupif(x) { if (x) goto fail; }
-extern int my_execve(char *path, char **av, char **ev) {
+extern int rc_execve(char *path, char **av, char **ev) {
int fd, len, fst, snd, end;
bool noarg;
char pb[256]; /* arbitrary but generous limit */
diff --git a/input.c b/input.c
@@ -120,7 +120,7 @@ static int fdgchar() {
if (chars_out >= chars_in + 2) { /* has the buffer been exhausted? if so, replenish it */
while (1) {
#if READLINE
- if (interactive && istack->fd == 0) {
+ if (interactive && istack->fd == 0 && isatty(0)) {
rlinebuf = rc_readline(prompt);
if (rlinebuf == NULL) {
chars_in = 0;
diff --git a/rc.h b/rc.h
@@ -220,8 +220,12 @@ extern void sigint(int);
extern void exec(List *, bool);
extern void doredirs(void);
+#if HASH_BANG
+#define rc_execve execve
+#else
/* execve.c */
extern int my_execve(char *, char **, char **);
+#endif
/* footobar.c */
extern char **list2array(List *, bool);