Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      sig_atomic_t

      From cppreference.com
      <c‎ |program
       
       
      Program support utilities
      Program termination
      Unreachable control flow
      Communicating with the environment
      Memory alignment query
      Signals
      sig_atomic_t
      Signal types
      Non-local jumps
      Types
       
      Defined in header<signal.h>
      typedef/* unspecified */ sig_atomic_t;

      An integer type which can be accessed as an atomic entity even in the presence of asynchronous interrupts made by signals.

      [edit]Example

      Run this code
      #include <signal.h>#include <stdio.h> volatile sig_atomic_t gSignalStatus=0; void signal_handler(int status){    gSignalStatus= status;} int main(void){/* Install a signal handler. */signal(SIGINT, signal_handler); printf("SignalValue:    %d\n", gSignalStatus);printf("Sending signal: %d\n",SIGINT);raise(SIGINT);printf("SignalValue:    %d\n", gSignalStatus);}

      Possible output:

      SignalValue:    0Sending signal: 2SignalValue:    2

      [edit]References

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

      [edit]See also

      sets a signal handler for particular signal
      (function)[edit]
      C++ documentation forsig_atomic_t
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=c/program/sig_atomic_t&oldid=140328"

      [8]ページ先頭

      ©2009-2025 Movatter.jp