From: Ezra Peisach Date: Thu, 27 Apr 1995 16:41:15 +0000 (+0000) Subject: Use posix signals if present on the system (for OS's that only have X-Git-Tag: krb5-1.0-beta5~210 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e4197f0ec15f5ae1a5f35c6b20e48337855c4e33;p=krb5.git Use posix signals if present on the system (for OS's that only have signal in BSD compatibility libraries) git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@5542 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/util/ss/ChangeLog b/src/util/ss/ChangeLog index d3feb1bed..1e85c2a24 100644 --- a/src/util/ss/ChangeLog +++ b/src/util/ss/ChangeLog @@ -1,3 +1,17 @@ +Thu Apr 27 12:26:26 1995 Ezra Peisach + + * pager.c: Use posix signals. + + * listen.c: Use posix signals. + + * list_rqs.c: Use posix signals. + + * help.c: Call wait with proper casting (int * vs. union wait *) + + * configure.in: Add AC_PROG_ARCHIVE_ADD and CHECK_SIGNALS. + + * Makefile.in (all): Use ARADD for incremental changes to library + Tue Mar 28 18:51:08 1995 John Gilmore (gnu at toad.com) * Makefile.in (all): Run all-$(WHAT). diff --git a/src/util/ss/Makefile.in b/src/util/ss/Makefile.in index d0dc57c86..d43df844f 100644 --- a/src/util/ss/Makefile.in +++ b/src/util/ss/Makefile.in @@ -110,7 +110,7 @@ ct.tab.c ct.tab.h: ct.y all:: libss.a libss.a: $(OBJS) - $(ARCHIVE) $@ $(OBJS) + $(ARADD) $@ $(OBJS) $(RANLIB) $@ clean:: diff --git a/src/util/ss/configure.in b/src/util/ss/configure.in index 596c007c6..bc755141b 100644 --- a/src/util/ss/configure.in +++ b/src/util/ss/configure.in @@ -6,6 +6,7 @@ AC_PROG_LEX AC_PROG_YACC AC_PROG_AWK AC_PROG_ARCHIVE +AC_PROG_ARCHIVE_ADD AC_PROG_RANLIB HAVE_YYLINENO AC_FUNC_CHECK(strdup,AC_DEFINE(HAS_STRDUP)) @@ -14,6 +15,7 @@ SS_RULES CHECK_DIRENT CHECK_FCNTL CHECK_WAIT_TYPE +CHECK_SIGNALS CHECK_SIGPROCMASK AC_RETSIGTYPE AC_CHECK_HEADERS(stdarg.h) diff --git a/src/util/ss/help.c b/src/util/ss/help.c index ad3b90b1f..3cdf82b57 100644 --- a/src/util/ss/help.c +++ b/src/util/ss/help.c @@ -79,7 +79,11 @@ got_it: ss_page_stdin(); default: (void) close(fd); /* what can we do if it fails? */ +#ifdef WAIT_USES_INT + while (wait((int *)NULL) != child) { +#else while (wait((union wait *)NULL) != child) { +#endif /* do nothing if wrong pid */ }; } diff --git a/src/util/ss/list_rqs.c b/src/util/ss/list_rqs.c index c44ebeda8..dab17a2a2 100644 --- a/src/util/ss/list_rqs.c +++ b/src/util/ss/list_rqs.c @@ -34,7 +34,12 @@ ss_list_requests(argc, argv, sci_idx, info_ptr) FILE *output; int fd; int mask; +#ifdef POSIX_SIGNALS + struct sigaction nsig, osig; + sigset_t nmask, omask; +#else RETSIGTYPE (*func)(); +#endif #ifndef WAIT_USES_INT union wait waitb; #else @@ -44,11 +49,28 @@ ss_list_requests(argc, argv, sci_idx, info_ptr) DONT_USE(argc); DONT_USE(argv); +#ifdef POSIX_SIGNALS + sigemptyset(&nmask); + sigaddset(&nmask, SIGINT); + sigprocmask(SIG_BLOCK, &nmask, &omask); + + nsig.sa_handler = SIG_IGN; + sigemptyset(&nsig.sa_mask); + nsig.sa_flags = 0; + sigaction(SIGINT, &nsig, &osig); +#else mask = sigblock(sigmask(SIGINT)); func = signal(SIGINT, SIG_IGN); +#endif + fd = ss_pager_create(); output = fdopen(fd, "w"); + +#ifdef POSIX_SIGNALS + sigprocmask(SIG_SETMASK, &omask, (sigset_t *)0); +#else sigsetmask(mask); +#endif fprintf (output, "Available %s requests:\n\n", ss_info (sci_idx) -> subsystem_name); @@ -84,5 +106,9 @@ ss_list_requests(argc, argv, sci_idx, info_ptr) #ifndef NO_FORK wait(&waitb); #endif +#ifdef POSIX_SIGNALS + sigaction(SIGINT, &osig, (struct sigaction *)0); +#else (void) signal(SIGINT, func); +#endif } diff --git a/src/util/ss/listen.c b/src/util/ss/listen.c index dd4760198..dc6022614 100644 --- a/src/util/ss/listen.c +++ b/src/util/ss/listen.c @@ -47,32 +47,68 @@ int ss_listen (sci_idx) int sci_idx; { register char *cp; - register RETSIGTYPE (*sig_cont)(); register ss_data *info; - RETSIGTYPE (*sig_int)(), (*old_sig_cont)(); char input[BUFSIZ]; char buffer[BUFSIZ]; char *end = buffer; - int mask; int code; jmp_buf old_jmpb; ss_data *old_info = current_info; +#ifdef POSIX_SIGNALS + struct sigaction isig, csig, nsig, osig; + sigset_t nmask, omask; +#else + register RETSIGTYPE (*sig_cont)(); + RETSIGTYPE (*sig_int)(), (*old_sig_cont)(); + int mask; +#endif current_info = info = ss_info(sci_idx); - sig_cont = (RETSIGTYPE (*)())0; info->abort = 0; + +#ifdef POSIX_SIGNALS + csig.sa_handler = (RETSIGTYPE (*)())0; + sigemptyset(&nmask); + sigaddset(&nmask, SIGINT); + sigprocmask(SIG_BLOCK, &nmask, &omask); +#else + sig_cont = (RETSIGTYPE (*)())0; mask = sigblock(sigmask(SIGINT)); +#endif + memcpy(old_jmpb, listen_jmpb, sizeof(jmp_buf)); + +#ifdef POSIX_SIGNALS + nsig.sa_handler = listen_int_handler; + sigemptyset(&nsig.sa_mask); + nsig.sa_flags = 0; + sigaction(SIGINT, &nsig, &isig); +#else sig_int = signal(SIGINT, listen_int_handler); +#endif + setjmp(listen_jmpb); + +#ifdef POSIX_SIGNALS + sigprocmask(SIG_SETMASK, &omask, (sigset_t *)0); +#else (void) sigsetmask(mask); +#endif while(!info->abort) { print_prompt(); *end = '\0'; +#ifdef POSIX_SIGNALS + nsig.sa_handler = listen_int_handler; /* fgets is not signal-safe */ + osig = csig; + sigaction(SIGCONT, &nsig, &csig); + if ((RETSIGTYPE (*)())csig.sa_handler==(RETSIGTYPE (*)())listen_int_handler) + csig = osig; +#else old_sig_cont = sig_cont; sig_cont = signal(SIGCONT, print_prompt); if (sig_cont == print_prompt) sig_cont = old_sig_cont; +#endif if (fgets(input, BUFSIZ, stdin) != input) { code = SS_ET_EOF; goto egress; @@ -83,7 +119,11 @@ int ss_listen (sci_idx) if (cp == input) continue; } +#ifdef POSIX_SIGNALS + sigaction(SIGCONT, &csig, (struct sigaction *)0); +#else (void) signal(SIGCONT, sig_cont); +#endif for (end = input; *end; end++) ; @@ -105,7 +145,11 @@ int ss_listen (sci_idx) } code = 0; egress: +#ifdef POSIX_SIGNALS + sigaction(SIGINT, &isig, (struct sigaction *)0); +#else (void) signal(SIGINT, sig_int); +#endif memcpy(listen_jmpb, old_jmpb, sizeof(jmp_buf)); current_info = old_info; return code; diff --git a/src/util/ss/pager.c b/src/util/ss/pager.c index b951fa638..1aaafeab8 100644 --- a/src/util/ss/pager.c +++ b/src/util/ss/pager.c @@ -67,13 +67,30 @@ int ss_pager_create() void ss_page_stdin() { int i; +#ifdef POSIX_SIGNALS + struct sigaction sa; + sigset_t mask; +#endif for (i = 3; i < 32; i++) (void) close(i); +#ifdef POSIX_SIGNALS + sa.sa_handler = SIG_DFL; + sigemptyset(&sa.sa_mask); + sa.sa_flags = 0; + sigaction(SIGINT, &sa, (struct sigaction *)0); +#else (void) signal(SIGINT, SIG_DFL); +#endif { +#ifdef POSIX_SIGNALS + sigemptyset(&mask); + sigaddset(&mask, SIGINT); + sigprocmask(SIG_UNBLOCK, &mask, (sigset_t *)0); +#else int mask = sigblock(0); mask &= ~sigmask(SIGINT); sigsetmask(mask); +#endif } if (_ss_pager_name == (char *)NULL) { if ((_ss_pager_name = getenv("PAGER")) == (char *)NULL)