apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gst...@apache.org
Subject cvs commit: apr/include apr_signal.h apr.h.in apr_want.h
Date Sun, 11 Feb 2001 00:39:55 GMT
gstein      01/02/10 16:39:55

  Modified:    .        configure.in
               threadproc/os2 signals.c
               threadproc/unix signals.c
               misc/unix start.c
               include  apr.h.in apr_want.h
  Added:       include  apr_signal.h
  Log:
  *) add apr_signal_get_description() to that platforms (which have signals)
     can portably get descriptions for them.
  *) move signal stuff from apr.h to (new) apr_signal.h
  *) os2/signals.c was collapsed into unix/signals.c
  *) APR initialization will init the signal names (if needed)
  
  Revision  Changes    Path
  1.224     +3 -3      apr/configure.in
  
  Index: configure.in
  ===================================================================
  RCS file: /home/cvs/apr/configure.in,v
  retrieving revision 1.223
  retrieving revision 1.224
  diff -u -u -r1.223 -r1.224
  --- configure.in	2001/02/10 18:09:27	1.223
  +++ configure.in	2001/02/11 00:39:54	1.224
  @@ -231,13 +231,15 @@
   dnl #----------------------------- Checks for Any required Functions
   dnl Checks for library functions. (N.B. poll is further down)
   AC_CHECK_FUNCS(strcasecmp stricmp setsid nl_langinfo)
  -AC_CHECK_FUNCS(sigaction, [ have_sigaction="1" ], [ have_sigaction="0" ]) 
   AC_CHECK_FUNCS(setrlimit, [ have_setrlimit="1" ], [ have_setrlimit="0" ]) 
   AC_CHECK_FUNCS(getrlimit, [ have_getrlimit="1" ], [ have_getrlimit="0" ]) 
   AC_CHECK_FUNCS(writev)
   sendfile="0"
   AC_CHECK_FUNCS(sendfile send_file, [ sendfile="1" ])
   
  +AC_CHECK_FUNCS(sigaction, [ have_sigaction="1" ], [ have_sigaction="0" ]) 
  +AC_DECL_SYS_SIGLIST
  +
   AC_CHECK_FUNCS(fork, [ fork="1" ], [ fork="0" ])
   AC_CHECK_FUNCS(getpass)
   APR_CHECK_INET_ADDR
  @@ -255,7 +257,6 @@
   fi
   AC_CHECK_FUNCS(hstrerror)
   AC_CHECK_FUNCS(memmove, [ have_memmove="1" ], [have_memmove="0" ])
  -AC_CHECK_FUNCS(bzero, [ have_bzero="1" ], [ have_bzero="0"] )
   
   AC_SUBST(fork)
   AC_SUBST(have_inet_addr)
  @@ -266,7 +267,6 @@
   AC_SUBST(iconv)
   AC_SUBST(mmap)
   AC_SUBST(have_memmove)
  -AC_SUBST(have_bzero)
   
   dnl #----------------------------- Checks for Any required Headers
   AC_HEADER_STDC
  
  
  
  1.13      +1 -98     apr/threadproc/os2/signals.c
  
  Index: signals.c
  ===================================================================
  RCS file: /home/cvs/apr/threadproc/os2/signals.c,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -u -r1.12 -r1.13
  --- signals.c	2001/02/08 07:45:15	1.12
  +++ signals.c	2001/02/11 00:39:54	1.13
  @@ -1,98 +1 @@
  -/* ====================================================================
  - * The Apache Software License, Version 1.1
  - *
  - * Copyright (c) 2000 The Apache Software Foundation.  All rights
  - * reserved.
  - *
  - * Redistribution and use in source and binary forms, with or without
  - * modification, are permitted provided that the following conditions
  - * are met:
  - *
  - * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer.
  - *
  - * 2. Redistributions in binary form must reproduce the above copyright
  - *    notice, this list of conditions and the following disclaimer in
  - *    the documentation and/or other materials provided with the
  - *    distribution.
  - *
  - * 3. The end-user documentation included with the redistribution,
  - *    if any, must include the following acknowledgment:
  - *       "This product includes software developed by the
  - *        Apache Software Foundation (http://www.apache.org/)."
  - *    Alternately, this acknowledgment may appear in the software itself,
  - *    if and wherever such third-party acknowledgments normally appear.
  - *
  - * 4. The names "Apache" and "Apache Software Foundation" must
  - *    not be used to endorse or promote products derived from this
  - *    software without prior written permission. For written
  - *    permission, please contact apache@apache.org.
  - *
  - * 5. Products derived from this software may not be called "Apache",
  - *    nor may "Apache" appear in their name, without prior written
  - *    permission of the Apache Software Foundation.
  - *
  - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  - * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  - * SUCH DAMAGE.
  - * ====================================================================
  - *
  - * This software consists of voluntary contributions made by many
  - * individuals on behalf of the Apache Software Foundation.  For more
  - * information on the Apache Software Foundation, please see
  - * <http://www.apache.org/>.
  - */
  -
  -#define INCL_DOSEXCEPTIONS
  -#include "threadproc.h"
  -#include "fileio.h"
  -#include "apr_thread_proc.h"
  -#include "apr_file_io.h"
  -#include "apr_general.h"
  -#include <signal.h>
  -#include <string.h>
  -#include <sys/wait.h>
  -
  -apr_status_t apr_proc_kill(apr_proc_t *proc, int signal)
  -{
  -/* SIGTERM's don't work too well in OS/2 (only affects other EMX programs).
  -   CGIs may not be, esp. REXX scripts, so use a native call instead */
  -   
  -    apr_status_t rc;
  -    
  -    if ( signal == SIGTERM ) {
  -        rc = APR_OS2_STATUS(DosSendSignalException(proc->pid, XCPT_SIGNAL_BREAK));
  -    } else {
  -        rc = kill(proc->pid, signal) < 0 ? errno : APR_SUCCESS;
  -    }
  -    
  -    return rc;
  -}
  -
  -
  -
  -/*
  - * Replace standard signal() with the more reliable sigaction equivalent
  - * from W. Richard Stevens' "Advanced Programming in the UNIX Environment"
  - * (the version that does not automatically restart system calls).
  - */
  -Sigfunc *apr_signal(int signo, Sigfunc * func)
  -{
  -    struct sigaction act, oact;
  -
  -    act.sa_handler = func;
  -    sigemptyset(&act.sa_mask);
  -    act.sa_flags = 0;
  -    if (sigaction(signo, &act, &oact) < 0)
  -        return SIG_ERR;
  -    return oact.sa_handler;
  -}
  +#include "../unix/signals.c"
  
  
  
  1.16      +183 -9    apr/threadproc/unix/signals.c
  
  Index: signals.c
  ===================================================================
  RCS file: /home/cvs/apr/threadproc/unix/signals.c,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -u -r1.15 -r1.16
  --- signals.c	2001/02/08 07:45:17	1.15
  +++ signals.c	2001/02/11 00:39:54	1.16
  @@ -52,40 +52,214 @@
    * <http://www.apache.org/>.
    */
   
  +#define INCL_DOSEXCEPTIONS      /* for OS2 */
   #include "threadproc.h"
   #include "apr_private.h"
  -#include "apr_lib.h"
  -#if APR_HAVE_SIGNAL_H
  -#include <signal.h>
  -#endif
  +#include "apr_pools.h"
  +#include "apr_signal.h"
  +
  +#define APR_WANT_SIGNAL
  +#include "apr_want.h"
  +
  +#include <assert.h>
   
  -apr_status_t apr_proc_kill(apr_proc_t *proc, int sig)
  +
  +apr_status_t apr_proc_kill(apr_proc_t *proc, int signum)
   {
  -    if (kill(proc->pid, sig) == -1) {
  +#ifdef OS2
  +    /* SIGTERM's don't work too well in OS/2 (only affects other EMX
  +     * programs). CGIs may not be, esp. REXX scripts, so use a native
  +     * call instead
  +     */
  +    if (signum == SIGTERM) {
  +        return APR_OS2_STATUS(DosSendSignalException(proc->pid,
  +                                                     XCPT_SIGNAL_BREAK));
  +    }
  +#endif /* OS2 */
  +
  +    if (kill(proc->pid, signum) == -1) {
           return errno;
       }
  +
       return APR_SUCCESS;
   }
  +
  +
  +#ifdef HAVE_SIGACTION
   
  -#if !defined(NO_USE_SIGACTION) && defined(HAVE_SIGACTION)
   /*
    * Replace standard signal() with the more reliable sigaction equivalent
    * from W. Richard Stevens' "Advanced Programming in the UNIX Environment"
    * (the version that does not automatically restart system calls).
    */
  -Sigfunc *apr_signal(int signo, Sigfunc * func)
  +apr_sigfunc_t *apr_signal(int signo, apr_sigfunc_t * func)
   {
       struct sigaction act, oact;
   
       act.sa_handler = func;
       sigemptyset(&act.sa_mask);
       act.sa_flags = 0;
  -#ifdef  SA_INTERRUPT            /* SunOS */
  +#ifdef SA_INTERRUPT             /* SunOS */
       act.sa_flags |= SA_INTERRUPT;
   #endif
       if (sigaction(signo, &act, &oact) < 0)
           return SIG_ERR;
       return oact.sa_handler;
   }
  +
  +#endif /* HAVE_SIGACTION */
  +
  +
  +#ifdef SYS_SIGLIST_DECLARED
  +
  +void apr_signal_init(apr_pool_t *pglobal)
  +{
  +}
  +const char *apr_signal_get_description(int signum)
  +{
  +    return sys_siglist[signum];
  +}
  +
  +#else /* !SYS_SIGLIST_DECLARED */
  +
  +/* we need to roll our own signal description stuff */
  +
  +#if defined(NSIG)
  +#define APR_NUMSIG NSIG
  +#elif defined(_NSIG)
  +#define APR_NUMSIG _NSIG
  +#elif defined(__NSIG)
  +#define APR_NUMSIG __NSIG
  +#else
  +#define APR_NUMSIG 33   /* breaks on OS/390 with < 33; 32 is o.k. for most */
  +#endif
  +
  +static const char *signal_description[APR_NUMSIG];
  +
  +#define store_desc(index, string) \
  +	(assert(index < APR_NUMSIG), \
  +         signal_description[index] = string)
  +
  +void apr_signal_init(apr_pool_t *pglobal)
  +{
  +    int sig;
  +
  +    store_desc(0, "Signal 0");
  +
  +#ifdef SIGHUP
  +    store_desc(SIGHUP, "Hangup");
  +#endif
  +#ifdef SIGINT
  +    store_desc(SIGINT, "Interrupt");
  +#endif
  +#ifdef SIGQUIT
  +    store_desc(SIGQUIT, "Quit");
  +#endif
  +#ifdef SIGILL
  +    store_desc(SIGILL, "Illegal instruction");
  +#endif
  +#ifdef SIGTRAP
  +    store_desc(SIGTRAP, "Trace/BPT trap");
  +#endif
  +#ifdef SIGIOT
  +    store_desc(SIGIOT, "IOT instruction");
  +#endif
  +#ifdef SIGABRT
  +    store_desc(SIGABRT, "Abort");
   #endif
  +#ifdef SIGEMT
  +    store_desc(SIGEMT, "Emulator trap");
  +#endif
  +#ifdef SIGFPE
  +    store_desc(SIGFPE, "Arithmetic exception");
  +#endif
  +#ifdef SIGKILL
  +    store_desc(SIGKILL, "Killed");
  +#endif
  +#ifdef SIGBUS
  +    store_desc(SIGBUS, "Bus error");
  +#endif
  +#ifdef SIGSEGV
  +    store_desc(SIGSEGV, "Segmentation fault");
  +#endif
  +#ifdef SIGSYS
  +    store_desc(SIGSYS, "Bad system call");
  +#endif
  +#ifdef SIGPIPE
  +    store_desc(SIGPIPE, "Broken pipe");
  +#endif
  +#ifdef SIGALRM
  +    store_desc(SIGALRM, "Alarm clock");
  +#endif
  +#ifdef SIGTERM
  +    store_desc(SIGTERM, "Terminated");
  +#endif
  +#ifdef SIGUSR1
  +    store_desc(SIGUSR1, "User defined signal 1");
  +#endif
  +#ifdef SIGUSR2
  +    store_desc(SIGUSR2, "User defined signal 2");
  +#endif
  +#ifdef SIGCLD
  +    store_desc(SIGCLD, "Child status change");
  +#endif
  +#ifdef SIGCHLD
  +    store_desc(SIGCHLD, "Child status change");
  +#endif
  +#ifdef SIGPWR
  +    store_desc(SIGPWR, "Power-fail restart");
  +#endif
  +#ifdef SIGWINCH
  +    store_desc(SIGWINCH, "Window changed");
  +#endif
  +#ifdef SIGURG
  +    store_desc(SIGURG, "urgent socket condition");
  +#endif
  +#ifdef SIGPOLL
  +    store_desc(SIGPOLL, "Pollable event occurred");
  +#endif
  +#ifdef SIGIO
  +    store_desc(SIGIO, "socket I/O possible");
  +#endif
  +#ifdef SIGSTOP
  +    store_desc(SIGSTOP, "Stopped (signal)");
  +#endif
  +#ifdef SIGTSTP
  +    store_desc(SIGTSTP, "Stopped");
  +#endif
  +#ifdef SIGCONT
  +    store_desc(SIGCONT, "Continued");
  +#endif
  +#ifdef SIGTTIN
  +    store_desc(SIGTTIN, "Stopped (tty input)");
  +#endif
  +#ifdef SIGTTOU
  +    store_desc(SIGTTOU, "Stopped (tty output)");
  +#endif
  +#ifdef SIGVTALRM
  +    store_desc(SIGVTALRM, "virtual timer expired");
  +#endif
  +#ifdef SIGPROF
  +    store_desc(SIGPROF, "profiling timer expired");
  +#endif
  +#ifdef SIGXCPU
  +    store_desc(SIGXCPU, "exceeded cpu limit");
  +#endif
  +#ifdef SIGXFSZ
  +    store_desc(SIGXFSZ, "exceeded file size limit");
  +#endif
  +
  +    for (sig = 0; sig < APR_NUMSIG; ++sig)
  +        if (signal_description[sig] == NULL)
  +            signal_description[sig] = apr_psprintf(pglobal, "signal #%d", sig);
  +}
  +
  +const char *apr_signal_get_description(int signum)
  +{
  +    return
  +        signum < APR_NUMSIG
  +        ? signal_description[signum]
  +        : "unknown signal (number)";
  +}
   
  +#endif /* SYS_SIGLIST_DECLARED */
  
  
  
  1.48      +8 -2      apr/misc/unix/start.c
  
  Index: start.c
  ===================================================================
  RCS file: /home/cvs/apr/misc/unix/start.c,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -u -r1.47 -r1.48
  --- start.c	2001/02/08 07:44:53	1.47
  +++ start.c	2001/02/11 00:39:54	1.48
  @@ -55,6 +55,7 @@
   #include "apr.h"
   #include "apr_general.h"
   #include "apr_pools.h"
  +#include "apr_signal.h"
   
   #include "misc.h"       /* for WSAHighByte / WSALowByte */
   #include "locks.h"      /* for apr_unix_setup_lock() */
  @@ -94,8 +95,13 @@
           return APR_EEXIST;
       }
   #endif
  -    status = apr_pool_alloc_init(global_apr_pool);
  -    return status;
  +
  +    if ((status = apr_pool_alloc_init(global_apr_pool)) != APR_SUCCESS)
  +        return status;
  +
  +    apr_signal_init(global_apr_pool);
  +
  +    return APR_SUCCESS;
   }
   
   APR_DECLARE(void) apr_terminate(void)
  
  
  
  1.65      +12 -26    apr/include/apr.h.in
  
  Index: apr.h.in
  ===================================================================
  RCS file: /home/cvs/apr/include/apr.h.in,v
  retrieving revision 1.64
  retrieving revision 1.65
  diff -u -u -r1.64 -r1.65
  --- apr.h.in	2001/01/28 15:30:25	1.64
  +++ apr.h.in	2001/02/11 00:39:55	1.65
  @@ -70,23 +70,23 @@
   #define APR_FILE_BASED_SHM      @file_based@
   #define APR_MEM_BASED_SHM       @mem_based@
   
  +#define APR_HAVE_CORKABLE_TCP   @have_corkable_tcp@ 
  +#define APR_HAVE_GETRLIMIT      @have_getrlimit@
   #define APR_HAVE_IN_ADDR        @have_in_addr@
   #define APR_HAVE_INET_ADDR      @have_inet_addr@
   #define APR_HAVE_INET_NETWORK   @have_inet_network@
  -#define APR_HAVE_UNION_SEMUN    @have_union_semun@
  -#define APR_HAVE_STRUCT_RLIMIT  @struct_rlimit@
  +#define APR_HAVE_IPV6           @have_ipv6@
  +#define APR_HAVE_MEMMOVE        @have_memmove@
   #define APR_HAVE_SETRLIMIT      @have_setrlimit@
  -#define APR_HAVE_GETRLIMIT      @have_getrlimit@
  -#define APR_HAVE_STRICMP        @have_stricmp@
  -#define APR_HAVE_STRNICMP       @have_strnicmp@
  +#define APR_HAVE_SIGACTION      @have_sigaction@
   #define APR_HAVE_STRCASECMP     @have_strcasecmp@
  -#define APR_HAVE_STRNCASECMP    @have_strncasecmp@
   #define APR_HAVE_STRDUP         @have_strdup@
  +#define APR_HAVE_STRICMP        @have_stricmp@
  +#define APR_HAVE_STRNCASECMP    @have_strncasecmp@
  +#define APR_HAVE_STRNICMP       @have_strnicmp@
   #define APR_HAVE_STRSTR         @have_strstr@
  -#define APR_HAVE_MEMMOVE        @have_memmove@
  -#define APR_HAVE_BZERO          @have_bzero@
  -#define APR_HAVE_IPV6           @have_ipv6@
  -#define APR_HAVE_CORKABLE_TCP   @have_corkable_tcp@ 
  +#define APR_HAVE_STRUCT_RLIMIT  @struct_rlimit@
  +#define APR_HAVE_UNION_SEMUN    @have_union_semun@
   
   #if APR_HAVE_SYS_TYPES_H
   #include <sys/types.h>
  @@ -177,6 +177,7 @@
    * @deffunc APR_DECLARE(rettype) apr_func(args);
    */
   #define APR_DECLARE(type)            type
  +
   /**
    * The public APR functions using variable arguments are declared with 
    * AP_DECLARE(), as they must use the C language calling convention.
  @@ -184,6 +185,7 @@
    * @deffunc APR_DECLARE_NONSTD(rettype) apr_func(args, ...);
    */
   #define APR_DECLARE_NONSTD(type)     type
  +
   /**
    * The public APR variables are declared with AP_MODULE_DECLARE_DATA.
    * This assures the appropriate indirection is invoked at compile time.
  @@ -212,22 +214,6 @@
   
   /* Local machine definition for console and log output. */
   #define APR_EOL_STR              "@eolstr@"
  -
  -/* Define apr_signal and related necessary definitions.
  - */
  -/* We are checking for HAVE_SIGACTION, but autoconf is filling this in 
  - * for us automatically.
  - */
  -#if @have_sigaction@ && !defined(NO_USE_SIGACTION)
  -typedef void Sigfunc(int);
  -Sigfunc *apr_signal(int signo, Sigfunc * func);
  -
  -#if defined(SIG_ING) && !defined(SIG_ERR)
  -#define SIG_ERR ((Sigfunc *)-1)
  -#endif
  -#else
  -#define apr_signal(a,b) signal(a,b)
  -#endif
   
   #if APR_HAVE_SYS_WAIT_H
   
  
  
  
  1.4       +13 -0     apr/include/apr_want.h
  
  Index: apr_want.h
  ===================================================================
  RCS file: /home/cvs/apr/include/apr_want.h,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -u -r1.3 -r1.4
  --- apr_want.h	2001/02/05 05:22:30	1.3
  +++ apr_want.h	2001/02/11 00:39:55	1.4
  @@ -61,6 +61,7 @@
    *   APR_WANT_MEMFUNC:  memcmp, memcpy, etc
    *   APR_WANT_STDIO:    <stdio.h> and related bits
    *   APR_WANT_IOVEC:    struct iovec
  + *   APR_WANT_SIGNAL:   signal numbers, functions, and types
    *
    * Typical usage:
    *
  @@ -119,6 +120,18 @@
   #endif
   
   #undef APR_WANT_IOVEC
  +#endif
  +
  +/* --------------------------------------------------------------------- */
  +
  +#ifdef APR_WANT_SIGNAL
  +
  +#if APR_HAVE_SIGNAL_H
  +#include <signal.h>
  +#endif
  +/* ### some platforms may put this into unistd.h ?? */
  +
  +#undef APR_WANT_SIGNAL
   #endif
   
   /* --------------------------------------------------------------------- */
  
  
  
  1.5       +37 -6     apr/include/apr_signal.h
  
  
  
  

Mime
View raw message