Mercurial > hg > CbC > CbC_gcc
view gcc/testsuite/gcc.dg/analyzer/signal-1.c @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | |
children |
line wrap: on
line source
/* Example of a bad call within a signal handler. 'handler' calls 'custom_logger' which calls 'fprintf', and 'fprintf' is not allowed from a signal handler. */ #include <stdio.h> #include <signal.h> extern void body_of_program(void); void custom_logger(const char *msg) { fprintf(stderr, "LOG: %s", msg); /* { dg-warning "call to 'fprintf' from within signal handler" } */ } static void handler(int signum) { custom_logger("got signal"); } int main(int argc, const char *argv) { custom_logger("started"); signal(SIGINT, handler); /* { dg-message "registering 'handler' as signal handler" } */ body_of_program(); custom_logger("stopped"); return 0; }