signal.c 842 B

12345678910111213141516171819202122232425262728
  1. #include "lib.h"
  2. #include <signal.h>
  3. int (*vectab[NSIG])(); /* array of functions to catch signals */
  4. /* The definition of signal really should be
  5. * PUBLIC int (*signal(signr, func))()
  6. * but some compilers refuse to accept this, even though it is correct.
  7. * The only thing to do if you are stuck with such a defective compiler is
  8. * change it to
  9. * PUBLIC int *signal(signr, func)
  10. * and change ../h/signal.h accordingly.
  11. */
  12. PUBLIC int (*signal(signr, func))()
  13. int signr; /* which signal is being set */
  14. int (*func)(); /* pointer to function that catches signal */
  15. {
  16. int r,(*old)();
  17. old = vectab[signr - 1];
  18. vectab[signr - 1] = func;
  19. M.m6_i1 = signr;
  20. M.m6_f1 = ( (func == SIG_IGN || func == SIG_DFL) ? func : begsig);
  21. r = callx(MM, SIGNAL);
  22. if (r == 1) old = SIG_IGN;
  23. return( (r < 0 ? (int (*)()) r : old) );
  24. }