Путеводитель по Руководству Linux

  User  |  Syst  |  Libr  |  Device  |  Files  |  Other  |  Admin  |  Head  |



   sigaction    ( 2 )

изучить и изменить сигнальное действие (examine and change a signal action)

  Name  |  Synopsis  |  Description  |  Return value  |  Error  |  Conforming to  |  Note  |  Bugs  |    Examples    |  See also  |

Примеры (Examples)

See mprotect(2).

Probing for flag support The following example program exits with status EXIT_SUCCESS if SA_EXPOSE_TAGBITS is determined to be supported, and EXIT_FAILURE otherwise.

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

void handler(int signo, siginfo_t *info, void *context) { struct sigaction oldact;

if (sigaction(SIGSEGV, NULL, &oldact) == -1 || (oldact.sa_flags & SA_UNSUPPORTED) || !(oldact.sa_flags & SA_EXPOSE_TAGBITS)) { _exit(EXIT_FAILURE); } _exit(EXIT_SUCCESS); }

int main(void) { struct sigaction act = { 0 };

act.sa_flags = SA_SIGINFO | SA_UNSUPPORTED | SA_EXPOSE_TAGBITS; act.sa_sigaction = &handler; if (sigaction(SIGSEGV, &act, NULL) == -1) { perror("sigaction"); exit(EXIT_FAILURE); }

raise(SIGSEGV); }