strsignal.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* vi: set sw=4 ts=4: */
  2. /* Copyright (C) 2000 Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
  3. * This file is part of the uC-Linux and is distributed under the
  4. * GNU Library General Public License.
  5. */
  6. #include <string.h>
  7. #include <malloc.h>
  8. #include <signal.h>
  9. extern char *itoa(int i);
  10. const char *const sys_siglist[] = {
  11. "Unknown signal",
  12. "Hangup",
  13. "Interrupt",
  14. "Quit",
  15. "Illegal instruction",
  16. "Trace/breakpoint trap",
  17. "IOT trap/Abort",
  18. "Bus error",
  19. "Floating point exception",
  20. "Killed",
  21. "User defined signal 1",
  22. "Segmentation fault",
  23. "User defined signal 2",
  24. "Broken pipe",
  25. "Alarm clock",
  26. "Terminated",
  27. "Stack fault",
  28. "Child exited",
  29. "Continued",
  30. "Stopped (signal)",
  31. "Stopped",
  32. "Stopped (tty input)",
  33. "Stopped (tty output)",
  34. "Urgent condition",
  35. "CPU time limit exceeded",
  36. "File size limit exceeded",
  37. "Virtual time alarm",
  38. "Profile signal",
  39. "Window size changed",
  40. "Possible I/O",
  41. "Power failure",
  42. "Unused signal",
  43. NULL
  44. };
  45. /********************** Function strsignal ************************************/
  46. char *strsignal(int sig)
  47. {
  48. static char retbuf[80];
  49. if (sys_siglist) {
  50. if (sig < 0 || sig >= _NSIG)
  51. goto unknown;
  52. strcpy(retbuf, sys_siglist[sig]);
  53. return retbuf;
  54. }
  55. if (sig <= 0)
  56. goto unknown;
  57. unknown:
  58. strcpy(retbuf, "Unknown Signal: ");
  59. strcat(retbuf, (char *) itoa(sig));
  60. return retbuf;
  61. }
  62. /********************** THE END ********************************************/