From a9de4d485ab79fd92396d35722c118dbe3b649e0 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Wed, 4 Oct 1995 03:46:35 +0000 Subject: Test SA_INTERRUPT, not _POSIX_VERSION, to determine whether `sigaction' functions are available. Reported by Paul Nevai . Fix suggested by Karl Berry. --- src/csplit.c | 8 ++++---- src/sort.c | 18 +++++++++--------- src/tac.c | 16 ++++++++-------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/csplit.c b/src/csplit.c index e80917d17..a81144a66 100644 --- a/src/csplit.c +++ b/src/csplit.c @@ -1435,9 +1435,9 @@ main (argc, argv) char **argv; { int optc; -#ifdef _POSIX_VERSION +#ifdef SA_INTERRUPT struct sigaction oldact, newact; -#endif /* _POSIX_VERSION */ +#endif /* SA_INTERRUPT */ program_name = argv[0]; global_argv = argv; @@ -1447,7 +1447,7 @@ main (argc, argv) remove_files = TRUE; prefix = DEFAULT_PREFIX; -#ifdef _POSIX_VERSION +#ifdef SA_INTERRUPT newact.sa_handler = interrupt_handler; sigemptyset (&newact.sa_mask); newact.sa_flags = 0; @@ -1467,7 +1467,7 @@ main (argc, argv) sigaction (SIGTERM, NULL, &oldact); if (oldact.sa_handler != SIG_IGN) sigaction (SIGTERM, &newact, NULL); -#else /* !_POSIX_VERSION */ +#else if (signal (SIGHUP, SIG_IGN) != SIG_IGN) signal (SIGHUP, interrupt_handler); if (signal (SIGINT, SIG_IGN) != SIG_IGN) diff --git a/src/sort.c b/src/sort.c index 787b22076..87f2fb469 100644 --- a/src/sort.c +++ b/src/sort.c @@ -32,7 +32,7 @@ #include "long-options.h" #include "error.h" -#ifdef _POSIX_VERSION +#ifdef HAVE_LIMITS_H #include #else #ifndef UCHAR_MAX @@ -1411,16 +1411,16 @@ static void sighandler (sig) int sig; { -#ifdef _POSIX_VERSION +#ifdef SA_INTERRUPT struct sigaction sigact; sigact.sa_handler = SIG_DFL; sigemptyset (&sigact.sa_mask); sigact.sa_flags = 0; sigaction (sig, &sigact, NULL); -#else /* !_POSIX_VERSION */ +#else /* !SA_INTERRUPT */ signal (sig, SIG_DFL); -#endif /* _POSIX_VERSION */ +#endif /* SA_INTERRUPT */ cleanup (); kill (getpid (), sig); } @@ -1492,9 +1492,9 @@ main (argc, argv) int checkonly = 0, mergeonly = 0, nfiles = 0; char *minus = "-", *outfile = minus, **files, *tmp; FILE *ofp; -#ifdef _POSIX_VERSION +#ifdef SA_INTERRUPT struct sigaction oldact, newact; -#endif /* _POSIX_VERSION */ +#endif /* SA_INTERRUPT */ program_name = argv[0]; @@ -1507,7 +1507,7 @@ main (argc, argv) if (temp_file_prefix == NULL) temp_file_prefix = DEFAULT_TMPDIR; -#ifdef _POSIX_VERSION +#ifdef SA_INTERRUPT newact.sa_handler = sighandler; sigemptyset (&newact.sa_mask); newact.sa_flags = 0; @@ -1524,7 +1524,7 @@ main (argc, argv) sigaction (SIGTERM, NULL, &oldact); if (oldact.sa_handler != SIG_IGN) sigaction (SIGTERM, &newact, NULL); -#else /* !_POSIX_VERSION */ +#else /* !SA_INTERRUPT */ if (signal (SIGINT, SIG_IGN) != SIG_IGN) signal (SIGINT, sighandler); if (signal (SIGHUP, SIG_IGN) != SIG_IGN) @@ -1533,7 +1533,7 @@ main (argc, argv) signal (SIGPIPE, sighandler); if (signal (SIGTERM, SIG_IGN) != SIG_IGN) signal (SIGTERM, sighandler); -#endif /* !_POSIX_VERSION */ +#endif /* !SA_INTERRUPT */ gkey.sword = gkey.eword = -1; gkey.ignore = NULL; diff --git a/src/tac.c b/src/tac.c index 49af8b251..d2f59ab7c 100644 --- a/src/tac.c +++ b/src/tac.c @@ -270,9 +270,9 @@ tac_stdin () RETSIGTYPE (*sigint) (), (*sighup) (), (*sigpipe) (), (*sigterm) (); int errors; struct stat stats; -#ifdef _POSIX_VERSION +#ifdef SA_INTERRUPT struct sigaction oldact, newact; -#endif /* _POSIX_VERSION */ +#endif /* SA_INTERRUPT */ /* No tempfile is needed for "tac < file". Use fstat instead of checking for errno == ESPIPE because @@ -286,7 +286,7 @@ tac_stdin () if (S_ISREG (stats.st_mode)) return tac (0, _("standard input")); -#ifdef _POSIX_VERSION +#ifdef SA_INTERRUPT newact.sa_handler = cleanup; sigemptyset (&newact.sa_mask); newact.sa_flags = 0; @@ -310,7 +310,7 @@ tac_stdin () sigterm = oldact.sa_handler; if (sigterm != SIG_IGN) sigaction (SIGTERM, &newact, NULL); -#else /* !_POSIX_VERSION */ +#else /* !SA_INTERRUPT */ sigint = signal (SIGINT, SIG_IGN); if (sigint != SIG_IGN) signal (SIGINT, cleanup); @@ -326,7 +326,7 @@ tac_stdin () sigterm = signal (SIGTERM, SIG_IGN); if (sigterm != SIG_IGN) signal (SIGTERM, cleanup); -#endif /* _POSIX_VERSION */ +#endif /* SA_INTERRUPT */ save_stdin (); @@ -334,7 +334,7 @@ tac_stdin () unlink (tempfile); -#ifdef _POSIX_VERSION +#ifdef SA_INTERRUPT newact.sa_handler = sigint; sigaction (SIGINT, &newact, NULL); newact.sa_handler = sighup; @@ -343,12 +343,12 @@ tac_stdin () sigaction (SIGTERM, &newact, NULL); newact.sa_handler = sigpipe; sigaction (SIGPIPE, &newact, NULL); -#else /* !_POSIX_VERSION */ +#else /* !SA_INTERRUPT */ signal (SIGINT, sigint); signal (SIGHUP, sighup); signal (SIGTERM, sigterm); signal (SIGPIPE, sigpipe); -#endif /* _POSIX_VERSION */ +#endif /* SA_INTERRUPT */ return errors; } -- cgit v1.2.3-70-g09d2