Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      SIG_DFL, SIG_IGN

      From cppreference.com
      <c‎ |program
       
       
      Program support utilities
      Program termination
      Unreachable control flow
      Communicating with the environment
      Memory alignment query
      Signals
      SIG_DFLSIG_IGN
      Signal types
      Non-local jumps
      Types
       
      Defined in header<signal.h>
      #define SIG_DFL /*implementation defined*/
      #define SIG_IGN /*implementation defined*/

      TheSIG_DFL andSIG_IGN macros expand into integral expressions that are not equal to an address of any function. The macros define signal handling strategies forsignal() function.

      Constant Explanation
      SIG_DFL default signal handling
      SIG_IGN signal is ignored

      Contents

      [edit]Example

      Run this code
      #include <signal.h>#include <stdio.h> int main(void){/* using the default signal handler */raise(SIGTERM);printf("Exit main()\n");/* never reached */}

      Output:

      (none)

      [edit]Example

      Run this code
      #include <signal.h>#include <stdio.h> int main(void){/* ignoring the signal */signal(SIGTERM, SIG_IGN);raise(SIGTERM);printf("Exit main()\n");}

      Output:

      Exit main()

      [edit]References

      • C17 standard (ISO/IEC 9899:2018):
      • 7.14/3 Signal handling <signal.h> (p: 193)
      • C11 standard (ISO/IEC 9899:2011):
      • 7.14/3 Signal handling <signal.h> (p: 265)
      • C99 standard (ISO/IEC 9899:1999):
      • 7.14/3 Signal handling <signal.h> (p: 246)
      • C89/C90 standard (ISO/IEC 9899:1990):
      • 4.7 SIGNAL HANDLING <signal.h>

      [edit]See also

      C++ documentation forSIG_DFL,SIG_IGN
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=c/program/SIG_strategies&oldid=140329"

      [8]ページ先頭

      ©2009-2025 Movatter.jp