bug-cfengine
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Signal names with autoconf?


From: Nicolas Chuche
Subject: Re: Signal names with autoconf?
Date: Wed, 24 Apr 2002 00:11:22 +0200
User-agent: Gnus/5.090006 (Oort Gnus v0.06) Emacs/21.2.50 (i686-pc-linux-gnu)

address@hidden disait le 04/23/02 que :

[I've posted this on gnu.cfengine.bug but my uucp feed seems to half
work for the moment so I repost this on the list. Sorry if you read
it twice.

> Then you need to process that file somehow to extract the
> name/number association and get it into a table. I was asking
> whether autoconf's expert knowledge and tools could make
> this easy.

Someone suggest using the bash method.

I've got a look on bash way and I've modify it a bit to handle only
signals declared in global.c.

That works at least on linux (old and recent), aix (4.3), sco (5.0.5)
and solaris (2.?).

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
/* 
  borrowed from bash gnu bash code
  This is GPL
*/

#include <signal.h>
#include <stdlib.h>

#if !defined (NSIG)
#  define NSIG 100
#endif

char *signal_names[NSIG];

#define signal_names_size (sizeof(signal_names)/sizeof(signal_names[0]))

void
initialize_signames ()
{
  register int i;
  /*
    #if defined (SIGRTMAX) || defined (SIGRTMIN)
    int rtmin, rtmax, rtcnt;
    #endif
  */

  for (i = 1; i < signal_names_size; i++)
    signal_names[i] = (char *)NULL;

  signal_names[0] = "NOSIG";

#if defined (NOSIG)
  signal_names[NOSIG] = "NOSIG";
#endif

#if defined (SIGHUP)
  signal_names[SIGHUP] = "SIGHUP";
#endif

#if defined (SIGINT)
  signal_names[SIGINT] = "SIGINT";
#endif

#if defined (SIGQUIT)
  signal_names[SIGQUIT] = "SIGQUIT";
#endif

#if defined (SIGILL)
  signal_names[SIGILL] = "SIGILL";
#endif

#if defined (SIGTRAP)
  signal_names[SIGTRAP] = "SIGTRAP";
#endif

#if defined (SIGIOT)
  signal_names[SIGIOT] = "SIGIOT";
#endif

#if defined (SIGEMT)
  signal_names[SIGEMT] = "SIGEMT";
#endif

#if defined (SIGFPE)
  signal_names[SIGFPE] = "SIGFPE";
#endif

#if defined (SIGKILL)
  signal_names[SIGKILL] = "SIGKILL";
#endif

#if defined (SIGBUS)
  signal_names[SIGBUS] = "SIGBUS";
#endif

#if defined (SIGSEGV)
  signal_names[SIGSEGV] = "SIGSEGV";
#endif

#if defined (SIGSYS)
  signal_names[SIGSYS] = "SIGSYS";
#endif

#if defined (SIGPIPE)
  signal_names[SIGPIPE] = "SIGPIPE";
#endif

#if defined (SIGALRM)
  signal_names[SIGALRM] = "SIGALRM";
#endif

#if defined (SIGTERM)
  signal_names[SIGTERM] = "SIGTERM";
#endif

#if defined (SIGURG)
  signal_names[SIGURG] = "SIGURG";
#endif

#if defined (SIGSTOP)
  signal_names[SIGSTOP] = "SIGSTOP";
#endif

#if defined (SIGTSTP)
  signal_names[SIGTSTP] = "SIGTSTP";
#endif

#if defined (SIGCONT)
  signal_names[SIGCONT] = "SIGCONT";
#endif

#if defined (SIGCHLD)
  signal_names[SIGCHLD] = "SIGCHLD";
#endif

#if defined (SIGTTIN)
  signal_names[SIGTTIN] = "SIGTTIN";
#endif

#if defined (SIGTTOU)
  signal_names[SIGTTOU] = "SIGTTOU";
#endif

#if defined (SIGIO)
  signal_names[SIGIO] = "SIGIO";
#endif

#if defined (SIGXCPU)
  signal_names[SIGXCPU] = "SIGXCPU";
#endif

#if defined (SIGXFSZ)
  signal_names[SIGXFSZ] = "SIGXFSZ";
#endif

#if defined (SIGVTALRM)
  signal_names[SIGVTALRM] = "SIGVTALRM";
#endif

#if defined (SIGPROF)
  signal_names[SIGPROF] = "SIGPROF";
#endif

#if defined (SIGWINCH)
  signal_names[SIGWINCH] = "SIGWINCH";
#endif

#if defined (SIGLOST)
  signal_names[SIGLOST] = "SIGLOST";
#endif

#if defined (SIGUSR1)
  signal_names[SIGUSR1] = "SIGUSR1";
#endif

#if defined (SIGUSR2)
  signal_names[SIGUSR2] = "SIGUSR2";
#endif

  for (i = NSIG - 1; i > 0 && signal_names[i] == (char *)NULL ; i--)
    signal_names[i] = 0;

  for (; i > 0 ; i--)
        if (signal_names[i] == (char *)NULL)
      {
        signal_names[i] = (char *)malloc (18);
        if (signal_names[i])
          sprintf (signal_names[i], "SIGJUNK(%d)", i);
      }

}

void
write_signames (stream)
     FILE *stream;
{
  int i;

  printf ("/*   Do not edit.  Edit support/mksignames.c instead. */\n\n");
  printf ("/* A translation list so we can be polite to our users. */\n");
  printf ("PUBLIC char *SIGNALS[] = {\n");

  for (i = 0; i < NSIG && signal_names[i] != (char *)NULL; i++)
    printf ("    \"%s\",  /* %3d  */\n", signal_names[i], i);

  printf ("};\n");
}


int
main (void) {
  initialize_signames();
  write_signames();
  return 0;
}
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-



reply via email to

[Prev in Thread] Current Thread [Next in Thread]