Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: remove old BeOS support code



Amongst the autoconf tests for signals is a test for broken sigsuspend()
on BeOS. There are quite a few tests for BeOS (originating from
workers/7362) and they are easy to identify having been nicely
commented. If anyone is still running zsh on BeOS, they likely also want
a similar vintage of zsh. Given that the last release of BeOS was 24
years ago, it is probably time that we can remove those old configure
tests.

While you might argue that these aren't doing any actual harm, autoconf
tests can be fragile and in tracking history these tests have seen
maintenance work such as because of erroneous results on one or other
platform. And we need a configure switch to disable the tcsetpgrp() test
because it can fail without a controlling terminal so that's adding a
burden on people packaging zsh.

The one currently relevant BeOS inspired system is Haiku OS and
fortunately, that is available to run in a VM. 
The relevant tests on latest[1] haiku-os:

checking for sys/select.h... yes
checking if link() works... no
checking if kill(pid, 0) returns ESRCH correctly... yes
checking if POSIX sigsuspend() works... yes
checking if tcsetpgrp() actually works... yes
checking if getpwnam() is faked... no

So no hard links but otherwise it adheres to other modern systems rather
than BeOS 4.

So the patch below removes the other tests along with associated
fallback code, #ifdefs, documentation etc. The JOB_CONTROL #define does
predate the BeOS support but is removed in this patch given the absence
of anything left in autoconf to disable it.

For getpwnam(), Haiku is very much single-user. I didn't check what
getpwnam() returns but rather than the original BeOS problem of
CDABLEVARS never allowing for "Command not found", it's not triggering
even for "user".

Oliver

[1] I had to update my Haiku VM to bleeding edge because it was failing
to fetch an ncurses6_devel package for the release version. Zsh does
build and work just with a few test failures including one for an
UNKNOWN resource limit and all that need zpty.

diff --git a/INSTALL b/INSTALL
index f347a4480..8b139fa9b 100644
--- a/INSTALL
+++ b/INSTALL
@@ -576,13 +576,6 @@ shell is running in some privileged mode.  This is turned off by
 default as on some systems non-standard headers (in particular AIX) are
 required.  A direct fix for that problem would be appreciated.
 
-A test for the function tcsetpgrp is turned on by default.  The test
-needs to run the function to determine if the implementation is
-usable. However, this can cause problems when configure is run without
-a controlling terminal (eg. from cron).  To avoid this, use
---with-tcsetpgrp or --without-tcsetpgrp to tell configure whether the
-function should be used.
-
 Options For Configure
 ---------------------
 
diff --git a/Src/init.c b/Src/init.c
index 8c7776c7a..70e878e20 100644
--- a/Src/init.c
+++ b/Src/init.c
@@ -695,7 +695,6 @@ init_io(char *cmd)
     } else
 	opts[USEZLE] = 0;
 
-#ifdef JOB_CONTROL
     /* If interactive, make sure the shell is in the foreground and is the
      * process group leader.
      */
@@ -708,9 +707,6 @@ init_io(char *cmd)
 	    acquire_pgrp(); /* might also clear opts[MONITOR] */
 	}
     }
-#else
-    opts[MONITOR] = 0;
-#endif
 }
 
 /**/
@@ -718,7 +714,7 @@ mod_export void
 init_shout(void)
 {
     static char shoutbuf[BUFSIZ];
-#if defined(JOB_CONTROL) && defined(TIOCSETD) && defined(NTTYDISC)
+#if defined(TIOCSETD) && defined(NTTYDISC)
     int ldisc;
 #endif
 
@@ -729,7 +725,7 @@ init_shout(void)
 	return;
     }
 
-#if defined(JOB_CONTROL) && defined(TIOCSETD) && defined(NTTYDISC)
+#if defined(TIOCSETD) && defined(NTTYDISC)
     ldisc = NTTYDISC;
     ioctl(SHTTY, TIOCSETD, (char *)&ldisc);
 #endif
diff --git a/Src/options.c b/Src/options.c
index a0e1aa024..8b37ab5e8 100644
--- a/Src/options.c
+++ b/Src/options.c
@@ -877,7 +877,6 @@ dosetopt(int optno, int value, int force, char *new_opts)
 	}
 #endif /* HAVE_SETRESGID && HAVE_SETRESUID */
 
-#ifdef JOB_CONTROL
     } else if (!force && optno == MONITOR && value) {
 	if (new_opts[optno] == value)
 	    return 0;
@@ -887,14 +886,6 @@ dosetopt(int optno, int value, int force, char *new_opts)
 	    origpgrp = GETPGRP();
 	    acquire_pgrp();
 	}
-#else
-    } else if(optno == MONITOR && value) {
-	    return -1;
-#endif /* not JOB_CONTROL */
-#ifdef GETPWNAM_FAKED
-    } else if(optno == CDABLEVARS && value) {
-	    return -1;
-#endif /* GETPWNAM_FAKED */
     } else if ((optno == EMACSMODE || optno == VIMODE) && value) {
 	if (sticky && sticky->emulation)
 	    return -1;
diff --git a/Src/signals.c b/Src/signals.c
index 6eecbf7d5..86f1a49f6 100644
--- a/Src/signals.c
+++ b/Src/signals.c
@@ -216,7 +216,6 @@ signal_suspend(UNUSED(int sig), int wait_cmd)
     int ret;
 
     sigset_t set;
-    sigset_t oset;
 
     sigemptyset(&set);
 
@@ -229,13 +228,7 @@ signal_suspend(UNUSED(int sig), int wait_cmd)
 	  (sigtrapped[SIGINT] & ~ZSIG_IGNORED)))
 	sigaddset(&set, SIGINT);
 
-# ifdef BROKEN_POSIX_SIGSUSPEND
-    sigprocmask(SIG_SETMASK, &set, &oset);
-    ret = pause();
-    sigprocmask(SIG_SETMASK, &oset, NULL);
-# else /* not BROKEN_POSIX_SIGSUSPEND */
     ret = sigsuspend(&set);
-# endif /* BROKEN_POSIX_SIGSUSPEND */
 
     return ret;
 }
diff --git a/Src/zsh_system.h b/Src/zsh_system.h
index 5c004d53e..21446a9b1 100644
--- a/Src/zsh_system.h
+++ b/Src/zsh_system.h
@@ -369,8 +369,6 @@ struct timespec {
 # ifndef TIME_H_SELECT_H_CONFLICTS
 #  include <sys/select.h>
 # endif
-#elif defined(SELECT_IN_SYS_SOCKET_H)
-# include <sys/socket.h>
 #endif
 
 #if defined(__APPLE__) && defined(HAVE_SELECT)
@@ -803,16 +801,6 @@ extern short ospeed;
 #endif
 #endif
 
-/* Can't support job control without working tcsetgrp() */
-#ifdef BROKEN_TCSETPGRP
-#undef JOB_CONTROL
-#endif /* BROKEN_TCSETPGRP */
-
-#ifdef BROKEN_KILL_ESRCH
-#undef ESRCH
-#define ESRCH EINVAL
-#endif /* BROKEN_KILL_ESRCH */
-
 /* Can we do locale stuff? */
 #undef USE_LOCALE
 #if defined(CONFIG_LOCALE) && defined(HAVE_SETLOCALE) && defined(LC_ALL)
diff --git a/configure.ac b/configure.ac
index eab95105c..b2721fa77 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2119,20 +2119,6 @@ if test x$zsh_cv_header_sys_ioctl_h_ioctl_proto = xyes; then
   AC_DEFINE(IOCTL_IN_SYS_IOCTL)
 fi
 
-dnl -------------------
-dnl select() defined in <sys/socket.h>, ie BeOS R4.51
-dnl -------------------
-AH_TEMPLATE([SELECT_IN_SYS_SOCKET_H],
-[Define to 1 if select() is defined in <sys/socket.h>, ie BeOS R4.51])
-if test x$ac_cv_header_sys_select_h != xyes; then
-  AC_CACHE_CHECK(for select() in <sys/socket.h>,
-  zsh_cv_header_socket_h_select_proto,
-  [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/socket.h>]], [[fd_set fd;]])],[zsh_cv_header_socket_h_select_proto=yes],[zsh_cv_header_socket_h_select_proto=no])])
-  if test x$zsh_cv_header_socket_h_select_proto = xyes; then
-    AC_DEFINE(SELECT_IN_SYS_SOCKET_H)
-  fi
-fi
-
 dnl -----------
 dnl named FIFOs
 dnl -----------
@@ -2266,154 +2252,6 @@ if test x$zsh_cv_sys_link = xyes; then
   AC_DEFINE(HAVE_LINK)
 fi
 
-dnl -----------
-dnl test for whether kill(pid, 0) where pid doesn't exit
-dnl should set errno to ESRCH, but some like BeOS R4.51 set to EINVAL
-dnl -----------
-AC_CACHE_CHECK(if kill(pid, 0) returns ESRCH correctly,
-zsh_cv_sys_killesrch,
-[AC_RUN_IFELSE([AC_LANG_SOURCE([[
-#include <unistd.h>
-#include <signal.h>
-#include <errno.h>
-int main()
-{
-    int pid = (getpid() + 10000) & 0xffffff;
-    while (pid && (kill(pid, 0) == 0 || errno != ESRCH)) pid >>= 1;
-    return(errno!=ESRCH);
-}
-]])],[zsh_cv_sys_killesrch=yes],[zsh_cv_sys_killesrch=no],[zsh_cv_sys_killesrch=yes])])
-AH_TEMPLATE([BROKEN_KILL_ESRCH],
-[Define to 1 if kill(pid, 0) doesn't return ESRCH, ie BeOS R4.51.])
-if test x$zsh_cv_sys_killesrch = xno; then
-  AC_DEFINE(BROKEN_KILL_ESRCH)
-fi
-
-dnl -----------
-dnl if POSIX, test for working sigsuspend().
-dnl for instance, BeOS R4.51 is broken.
-dnl -----------
-AH_TEMPLATE([BROKEN_POSIX_SIGSUSPEND],
-Define to 1 if sigsuspend() is broken, ie BeOS R4.51.])
-    AC_CACHE_CHECK(if POSIX sigsuspend() works,
-    zsh_cv_sys_sigsuspend,
-    [AC_RUN_IFELSE([AC_LANG_SOURCE([[
-#include <signal.h>
-#include <unistd.h>
-int child=0;
-void handler(sig)
-    int sig;
-{if(sig==SIGCHLD) child=1;}
-int main() {
-    struct sigaction act;
-    sigset_t set;
-    int pid, ret;
-    act.sa_handler = &handler;
-    sigfillset(&act.sa_mask);
-    act.sa_flags = 0;
-    sigaction(SIGCHLD, &act, 0);
-    sigfillset(&set);
-    sigprocmask(SIG_SETMASK, &set, 0);
-    pid=fork();
-    if(pid==0) return 0;
-    if(pid>0) {
-    sigemptyset(&set);
-        ret=sigsuspend(&set);
-        return(child==0);
-    }
-}
-]])],[zsh_cv_sys_sigsuspend=yes],[zsh_cv_sys_sigsuspend=no],[zsh_cv_sys_sigsuspend=yes])])
-    if test x$zsh_cv_sys_sigsuspend = xno; then
-      AC_DEFINE(BROKEN_POSIX_SIGSUSPEND)
-    fi
-
-dnl -----------
-dnl if found tcsetpgrp, test to see if it actually works
-dnl for instance, BeOS R4.51 does not support it yet
-dnl -----------
-AH_TEMPLATE([BROKEN_TCSETPGRP],
-[Define to 1 if tcsetpgrp() doesn't work, ie BeOS R4.51.])
-AC_ARG_WITH(tcsetpgrp,
-AS_HELP_STRING([--with-tcsetpgrp],[assumes that tcsetpgrp() exists and works correctly]),[
-case "x$withval" in
-    xyes) zsh_working_tcsetpgrp=yes;;
-    xno)  zsh_working_tcsetpgrp=no;;
-    *)    AC_MSG_ERROR(please use --with-tcsetpgrp=yes or --with-tcsetpgrp=no);;
-esac],[zsh_working_tcsetpgrp=check])
-if test "x$ac_cv_func_tcsetpgrp" = xyes; then
-case "x$zsh_working_tcsetpgrp" in
-  xcheck)
-    trap "" TTOU > /dev/null 2>&1 || :
-    AC_CACHE_CHECK(if tcsetpgrp() actually works,
-    zsh_cv_sys_tcsetpgrp,
-    [AC_RUN_IFELSE([AC_LANG_SOURCE([[
-#include <sys/types.h>
-#include <unistd.h>
-#include <fcntl.h>
-int main() {
-    int fd;
-    int ret;
-    fd=open("/dev/tty", O_RDWR);
-    if (fd < 0) return(2);
-    ret=tcsetpgrp(fd, tcgetpgrp(fd));
-    if (ret < 0) return(1);
-    return(0);
-}
-]])],[zsh_cv_sys_tcsetpgrp=yes],[
-case $? in
-    1) zsh_cv_sys_tcsetpgrp=no;;
-    2) zsh_cv_sys_tcsetpgrp=notty;;
-    *) zsh_cv_sys_tcsetpgrp=error;;
-esac
-      ],[zsh_cv_sys_tcsetpgrp=yes])])
-    case "x$zsh_cv_sys_tcsetpgrp" in
-      xno)    AC_DEFINE(BROKEN_TCSETPGRP);;
-      xyes)   :;;
-      xnotty) AC_MSG_ERROR([no controlling tty
-Try running configure with --with-tcsetpgrp or --without-tcsetpgrp]);;
-      *)      AC_MSG_ERROR([unexpected return status]);;
-    esac
-    trap - TTOU > /dev/null 2>&1 || :
-    ;;
-  xyes) :;;
-  xno)  AC_DEFINE(BROKEN_TCSETPGRP);;
-  *)    AC_MSG_ERROR([unexpected value zsh_working_tcsetpgrp=$zsh_working_tcsetpgrp]);;
-esac
-fi
-
-dnl -----------
-dnl test for faked getpwnam() entry, ie a single entry returned for any username
-dnl for instance, BeOS R4.51 is not multiuser yet, and fakes getpwnam()
-dnl test by looking up two usernames that shouldn't succeed, and compare entry
-dnl -----------
-AH_TEMPLATE([GETPWNAM_FAKED],
-[Define to 1 if getpwnam() is faked, ie BeOS R4.51.])
-if test x$ac_cv_func_getpwnam = xyes; then
-    AC_CACHE_CHECK(if getpwnam() is faked,
-    zsh_cv_sys_getpwnam_faked,
-    [AC_RUN_IFELSE([AC_LANG_SOURCE([[
-#include <pwd.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-int main() {
-    struct passwd *pw1, *pw2;
-    char buf[1024], name[1024];
-    sprintf(buf, "%d:%d", getpid(), rand());
-    pw1=getpwnam(buf);
-    if (pw1) strcpy(name, pw1->pw_name);
-    sprintf(buf, "%d:%d", rand(), getpid());
-    pw2=getpwnam(buf);
-    return(pw1!=0 && pw2!=0 && !strcmp(name, pw2->pw_name));
-}
-]])],[zsh_cv_sys_getpwnam_faked=no],[zsh_cv_sys_getpwnam_faked=yes],[zsh_cv_sys_getpwnam_faked=no])])
-    if test x$zsh_cv_sys_getpwnam_faked = xyes; then
-      AC_DEFINE(GETPWNAM_FAKED)
-    fi
-fi
-
-
 dnl ---------------
 dnl check for the type of third argument of accept
 dnl ---------------
@@ -3151,9 +2989,6 @@ AH_TOP([/***** begin user configuration section *****/
 /* Define to 1 if you want user names to be cached */
 #define CACHE_USERNAMES 1
 
-/* Define to 1 if system supports job control */
-#define JOB_CONTROL 1
-
 /* Define this if you use "suspended" instead of "stopped" */
 #define USE_SUSPENDED 1
  




Messages sorted by: Reverse Date, Date, Thread, Author