Difference between revisions of "cpp/utility/program/raise"
From cppreference.com
(+see c) |
(+std::) |
||
(7 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
{{cpp/title| raise}} | {{cpp/title| raise}} | ||
− | {{cpp/utility/program/ | + | {{cpp/utility/program/navbar}} |
{{ddcl | header=csignal | | {{ddcl | header=csignal | | ||
int raise( int sig ); | int raise( int sig ); | ||
}} | }} | ||
− | Sends signal sig to the program. The signal handler | + | Sends signal sig to the program. The signal handler (specified using the {{lc|std::signal()}} function) is invoked. |
− | If the user-defined signal handling strategy is not set using {{ | + | If the user-defined signal handling strategy is not set using {{lc|std::signal()}} yet, it is implementation-defined whether the signal will be ignored or default handler will be invoked. |
===Parameters=== | ===Parameters=== | ||
− | {{ | + | {{par begin}} |
− | {{ | + | {{par | sig | the signal to be sent. It can be an implementation-defined value or one of the following values: |
− | {{ | + | {{dsc begin}} |
− | {{ | + | {{dsc inc | cpp/utility/program/dsc SIG_types}} |
− | {{ | + | {{dsc end}} |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
}} | }} | ||
− | {{ | + | {{par end}} |
===Return value=== | ===Return value=== | ||
Line 29: | Line 24: | ||
{{example | {{example | ||
| | | | ||
+ | | p=true | ||
| code= | | code= | ||
+ | #include <csignal> | ||
+ | #include <iostream> | ||
+ | |||
+ | void signal_handler(int signal) | ||
+ | { | ||
+ | std::cout << "Received signal " << signal << '\n'; | ||
+ | } | ||
+ | |||
+ | int main() | ||
+ | { | ||
+ | // Install a signal handler | ||
+ | std::signal(SIGTERM, signal_handler); | ||
+ | |||
+ | std::cout << "Sending signal " << SIGTERM << '\n'; | ||
+ | std::raise(SIGTERM); | ||
+ | } | ||
| output= | | output= | ||
+ | Sending signal 15 | ||
+ | Received signal 15 | ||
}} | }} | ||
===See also=== | ===See also=== | ||
− | {{ | + | {{dsc begin}} |
− | {{ | + | {{dsc inc | cpp/utility/program/dsc signal}} |
− | {{ | + | {{dsc see c | c/program/raise}} |
− | {{ | + | {{dsc end}} |
+ | [[de:cpp/utility/program/raise]] | ||
+ | [[es:cpp/utility/program/raise]] | ||
[[fr:cpp/utility/program/raise]] | [[fr:cpp/utility/program/raise]] | ||
+ | [[it:cpp/utility/program/raise]] | ||
[[ja:cpp/utility/program/raise]] | [[ja:cpp/utility/program/raise]] | ||
+ | [[pt:cpp/utility/program/raise]] | ||
+ | [[ru:cpp/utility/program/raise]] | ||
[[zh:cpp/utility/program/raise]] | [[zh:cpp/utility/program/raise]] |
Latest revision as of 07:53, 15 August 2013
Defined in header <csignal>
|
||
int raise( int sig ); |
||
Sends signal sig to the program. The signal handler (specified using the std::signal() function) is invoked.
If the user-defined signal handling strategy is not set using std::signal() yet, it is implementation-defined whether the signal will be ignored or default handler will be invoked.
Contents |
[edit] Parameters
sig | - | the signal to be sent. It can be an implementation-defined value or one of the following values:
|
[edit] Return value
0 upon success, non-zero value on failure.
[edit] Example
Run this code
Possible output:
Sending signal 15 Received signal 15
[edit] See also
sets a signal handler for particular signal (function) | |
C documentation for raise
|