make_siglist.c

Tor Lillqvist tml at hemuli.atk.vtt.fi
Fri Jun 9 23:02:19 AEST 1989


In article <3999 at hemuli.atk.vtt.fi> I write:
>With all the SysV/BSD hybrids out there, one cannot assume anything
>about the values of the SIG* macros.  Another problem is that
>sys_siglist isn't available on many systems.
>
>This program generates a file that defines the BSD-style sys_siglist
>array and a signal_names array.

Well, it seems as ULTRIX 2.0 is so brain-damaged that it does:

#define SIGPWR -1

So, here is a revised version of the make_siglist program:

/*
 * make_siglist -- create a file defining sys_siglist and signal_names
 *
 */

#include <stdio.h>
#include <sys/signal.h>

char *sys_siglist[NSIG];
char *signal_names[NSIG];

void
setup_siglist()
{
  int i;
  for (i = 0; i < NSIG; i++)
    sys_siglist[i] = NULL, signal_names[i] = NULL;

  sys_siglist[0] = "No signal";
  signal_names[0] = "ON_EXIT";
#if defined(SIGHUP) && SIGHUP > 0
  sys_siglist[SIGHUP] = "Hangup";
  signal_names[SIGHUP] = "SIGHUP";
#endif
#if defined(SIGINT) && SIGINT > 0
  sys_siglist[SIGINT] = "Interrupt";
  signal_names[SIGINT] = "SIGINT";
#endif
#if defined(SIGQUIT) && SIGQUIT > 0
  sys_siglist[SIGQUIT] = "Quit";
  signal_names[SIGQUIT] = "SIGQUIT";
#endif
#if defined(SIGILL) && SIGILL > 0
  sys_siglist[SIGILL] = "Illegal instruction";
  signal_names[SIGILL] = "SIGILL";
#endif
#if defined(SIGTRAP) && SIGTRAP > 0
  sys_siglist[SIGTRAP] = "Trace trap";
  signal_names[SIGTRAP] = "SIGTRAP";
#endif
#if defined(SIGABRT) && SIGABRT > 0
  sys_siglist[SIGABRT] = "Abnormal termination";
  signal_names[SIGABRT] = "SIGABRT";
#endif
#if defined(SIGIOT) && SIGIOT > 0 && (!defined(SIGABRT) || SIGIOT != SIGABRT)
  sys_siglist[SIGIOT] = "IOT instruction";
  signal_names[SIGIOT] = "SIGIOT";
#endif
#if defined(SIGEMT) && SIGEMT > 0
  sys_siglist[SIGEMT] = "EMT instruction";
  signal_names[SIGEMT] = "SIGEMT";
#endif
#if defined(SIGFPE) && SIGFPE > 0
  sys_siglist[SIGFPE] = "Floating point exception";
  signal_names[SIGFPE] = "SIGFPE";
#endif
#if defined(SIGKILL) && SIGKILL > 0
  sys_siglist[SIGKILL] = "Killed";
  signal_names[SIGKILL] = "SIGKILL";
#endif
#if defined(SIGBUS) && SIGBUS > 0
  sys_siglist[SIGBUS] = "Bus error";
  signal_names[SIGBUS] = "SIGBUS";
#endif
#if defined(SIGSEGV) && SIGSEGV > 0
  sys_siglist[SIGSEGV] = "Segmentation violation";
  signal_names[SIGSEGV] = "SIGSEG";
#endif
#if defined(SIGSYS) && SIGSYS > 0
  sys_siglist[SIGSYS] = "Bad argument to system call";
  signal_names[SIGSYS] = "SIGSYS";
#endif
#if defined(SIGPIPE) && SIGPIPE > 0
  sys_siglist[SIGPIPE] = "Write on pipe with no one reading";
  signal_names[SIGPIPE] = "SIGPIPE";
#endif
#if defined(SIGALRM) && SIGALRM > 0
  sys_siglist[SIGALRM] = "Alarm clock";
  signal_names[SIGALRM] = "SIGALRM";
#endif
#if defined(SIGTERM) && SIGTERM > 0
  sys_siglist[SIGTERM] = "Software termination";
  signal_names[SIGTERM] = "SIGTERM";
#endif
#if defined(SIGUSR1) && SIGUSR1 > 0
  sys_siglist[SIGUSR1] = "User defined signal 1";
  signal_names[SIGUSR1] = "SIGUSR1";
#endif
#if defined(SIGUSR2) && SIGUSR2 > 0
  sys_siglist[SIGUSR2] = "User defined signal 2";
  signal_names[SIGUSR2] = "SIGUSR2";
#endif
#if defined(SIGCLD) && SIGCLD > 0
  sys_siglist[SIGCLD] = "Death of child";
  signal_names[SIGCLD] = "SIGCLD";
#endif
#if defined(SIGCHLD) && SIGCHLD > 0 && (!defined(SIGCLD) || SIGCHLD != SIGCLD)
  sys_siglist[SIGCHLD] = "Death of child";
  signal_names[SIGCHLD] = "SIGCHLD";
#endif
#if defined(SIGPWR) && SIGPWR > 0
  sys_siglist[SIGPWR] = "Power fail restart";
  signal_names[SIGPWR] = "SIGPWR";
#endif
#if defined(SIGVTALRM) && SIGVTALRM > 0
  sys_siglist[SIGVTALRM] = "Virtual timer alarm clock";
  signal_names[SIGVTALRM] = "SIGVTALRM";
#endif
#if defined(SIGPROF) && SIGPROF > 0
  sys_siglist[SIGPROF] = "Profiling timer alarm clock";
  signal_names[SIGPROF] = "SIGPROF";
#endif
#if defined(SIGIO) && SIGIO > 0
  sys_siglist[SIGIO] = "Asynchronous I/O";
  signal_names[SIGIO] = "SIGIO";
#endif
#if defined(SIGWINDOW) && SIGWINDOW > 0
  sys_siglist[SIGWINDOW] = "Window changed";
  signal_names[SIGWINDOW] = "SIGWINDOW";
#endif
#if defined(SIGWINCH) && SIGWINCH > 0
  sys_siglist[SIGWINCH] = "Window changed";
  signal_names[SIGWINCH] = "SIGWINCH";
#endif
#if defined(SIGSTOP) && SIGSTOP > 0
  sys_siglist[SIGSTOP] = "Stopped";
  signal_names[SIGSTOP] = "SIGSTOP";
#endif
#if defined(SIGTSTP) && SIGTSTP > 0
  sys_siglist[SIGTSTP] = "Stopped from keyboard";
  signal_names[SIGTSTP] = "SIGTSTP";
#endif
#if defined(SIGCONT) && SIGCONT > 0
  sys_siglist[SIGCONT] = "Continued";
  signal_names[SIGCONT] = "SIGCONT";
#endif
#if defined(SIGTTIN) && SIGTTIN > 0
  sys_siglist[SIGTTIN] = "Attempted background read";
  signal_names[SIGTTIN] = "SIGTTIN";
#endif
#if defined(SIGTTOU) && SIGTTOU > 0
  sys_siglist[SIGTTOU] = "Attempted background write";
  signal_names[SIGTTOU] = "SIGTTOU";
#endif
#if defined(SIGURG) && SIGURG > 0
  sys_siglist[SIGURG] = "Urgent data";
  signal_names[SIGURG] = "SIGURG";
#endif
#if defined(SIGXCPU) && SIGXCPU > 0
  sys_siglist[SIGXCPU] = "CPU quota exceeded";
  signal_names[SIGXCPU] = "SIGXCPU";
#endif
#if defined(SIGXFSZ) && SIGXFSZ > 0
  sys_siglist[SIGXFSZ] = "File space quota exceeded";
  signal_names[SIGXFSZ] = "SIGXFSZ";
#endif
#if defined(SIGLOST) && SIGLOST > 0
  sys_siglist[SIGLOST] = "Resource lost";
  signal_names[SIGLOST] = "SIGLOST";
#endif
}

main()
{
  int i;

  setup_siglist();
  
  printf("/* This file was produced by running make_siglist.  Don't edit. */\n\
\n\
char *sys_siglist[] = {\n");
  for (i = 0; i < NSIG; i++) {
    sys_siglist[i] ?
      printf("  \"%s\"", sys_siglist[i]) :
	printf("  \"Signal %d\"", i);
    if (i < NSIG-1)
      putchar(',');
    putchar('\n');
  }
    
  printf("};\n\n");

  printf("char *signal_names[] = {\n");
  for (i = 0; i < NSIG; i++) {
    signal_names[i] ?
      printf("  \"%s\"", signal_names[i]) :
	printf("  \"0\"");
    if (i < NSIG-1)
      putchar(',');
    putchar('\n');
  }
  printf("};\n");

  exit(0);
}

-- 
Tor Lillqvist
Technical Research Centre of Finland, Computing Services (VTT/ATK)
tml at hemuli.atk.vtt.fi [130.188.52.2]



More information about the Alt.sources mailing list