File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1616#include <csignal>
1717#include <cstdlib>
1818
19- void handler(int sig )
19+ void handler(int)
2020{
2121 std::_Exit(0);
2222}
@@ -25,12 +25,10 @@ int main()
2525{
2626 std::signal(SIGILL, handler);
2727 std::raise(SIGILL);
28- return 0;
2928}
3029```
3130* SIGILL[color ff0000]
3231
3332### 出力
3433```
35- SIGILL received
3634```
Original file line number Diff line number Diff line change 1414## 例
1515```cpp example
1616#include <csignal>
17- #include <iostream >
17+ #include <cstdlib >
1818
1919volatile std::sig_atomic_t flag = 0;
2020
21- void handler(int sig )
21+ void handler(int)
2222{
23- flag = 1 ;
23+ std::_Exit(0) ;
2424}
2525
2626int main()
2727{
2828 std::signal(SIGINT, handler);
2929 std::raise(SIGINT);
30- if (flag)
31- {
32- std::cout << "SIGINT received" << std::endl;
33- }
3430 return 0;
3531}
3632```
3733* SIGINT[color ff0000]
3834
3935### 出力
4036```
41- SIGINT received
4237```
Original file line number Diff line number Diff line change 1616#include <csignal>
1717#include <cstdlib>
1818
19- void handler(int sig )
19+ void handler(int)
2020{
2121 std::_Exit(0);
2222}
You can’t perform that action at this time.
0 commit comments