Welcome to mirror list, hosted at ThFree Co, Russian Federation.

strsig.cc « cygwin « winsup - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6d3c479ec617f01a413e94f6d41a36636576c9ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/* strsig.cc

   Copyright 2004 Red Hat, Inc.

This file is part of Cygwin.

This software is a copyrighted work licensed under the terms of the
Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
details. */

#include "winsup.h"
#include "thread.h"
#include <time.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <cygtls.h>

struct sigdesc
{
  int n;
  const char *name;
  const char *str;
};

#define _s(n, s) {n, #n, s}
static const sigdesc siglist[] =
{
  _s(SIGHUP, "Hangup"),
  _s(SIGINT, "Interrupt"),
  _s(SIGQUIT, "Quit"),
  _s(SIGILL, "Illegal instruction"),
  _s(SIGTRAP, "Trace/breakpoint trap"),
  _s(SIGABRT, "Aborted"),
  _s(SIGEMT, "EMT instruction"),
  _s(SIGFPE, "Floating point exception"),
  _s(SIGKILL, "Killed"),
  _s(SIGBUS, "Bus error"),
  _s(SIGSEGV, "Segmentation fault"),
  _s(SIGSYS, "Bad system call"),
  _s(SIGPIPE, "Broken pipe"),
  _s(SIGALRM, "Alarm clock"),
  _s(SIGTERM, "Terminated"),
  _s(SIGURG, "Urgent I/O condition"),
  _s(SIGSTOP, "Stopped (signal)"),
  _s(SIGTSTP, "Stopped"),
  _s(SIGCONT, "Continued"),
  _s(SIGCHLD, "Child exited"),
  _s(SIGCLD, "Child exited"),
  _s(SIGTTIN, "Stopped (tty input)"),
  _s(SIGTTOU, "Stopped (tty output)"),
  _s(SIGIO, "I/O possible"),
  _s(SIGPOLL, "I/O possible"),
  _s(SIGXCPU, "CPU time limit exceeded"),
  _s(SIGXFSZ, "File size limit exceeded"),
  _s(SIGVTALRM, "Virtual timer expired"),
  _s(SIGPROF, "Profiling timer expired"),
  _s(SIGWINCH, "Window changed"),
  _s(SIGLOST, "Resource lost"),
  _s(SIGUSR1, "User defined signal 1"),
  _s(SIGUSR2, "User defined signal 2"),
  _s(SIGRTMIN, "Real-time signal 0"),
  _s(SIGRTMAX, "Real-time signal 0"),
  {0, NULL, NULL}
};

extern "C" const char *
strsignal (int signo)
{
  for (int i = 0; siglist[i].n; i++)
    if (siglist[i].n == signo)
      return siglist[i].str;
  __small_sprintf (_my_tls.locals.signamebuf, "Unknown signal %d", signo);
  return _my_tls.locals.signamebuf;
}

extern "C" int
strtosigno (const char *name)
{
  for (int i = 0; siglist[i].n; i++)
    if (strcmp (siglist[i].name, name) == 0)
      return siglist[i].n;
  return 0;
}