Open
Conversation
Contributor
| ## 概要 | ||
| `signal`関数に渡される引数として、シグナルに対するデフォルトの処理を指定するマクロ。 | ||
|
|
||
| シグナル受信時に`signal`関数で`SIG_DFL`が指定されている場合、そのシグナルに対する実装定義のデフォルト処理が実行される。 |
Member
There was a problem hiding this comment.
これは用途を記載したほうがいい気がしました。
シグナルハンドラーの登録を解除するものですよね。
サンプルコードもそのような用途を説明するものだとよいかと思います。
reference/csignal/sig_dfl.md
Outdated
|
|
||
| void signal_handler(int) | ||
| { | ||
| std::cout << "Custom handler\n"; |
Member
There was a problem hiding this comment.
シグナルハンドラでのcoutの使用は未定義動作なので、別なサンプルにするか、サンプルのためこうしてるが実際にはやってはいけないとコメントするかするのがよさそうです
akinomyoga
reviewed
Feb 27, 2026
reference/csignal/sig_dfl.md
Outdated
| std::signal(SIGINT, SIG_DFL); | ||
| std::cout << "Press Ctrl+C\n"; | ||
| // ここで Ctrl+C を押すと、デフォルト動作 | ||
| while (true) { |
Member
There was a problem hiding this comment.
これは最適化で消滅する可能性があるのでは。
それとも何か最近規格で動きがあったりしますか。巷ではUBとされていたのがP2809R3 で修正されて、消滅してよくなって、さらに P3881R0 (未採択) で何か議論しているみたいですが。
Member
There was a problem hiding this comment.
上は迂遠な書き方になってしまいましたが、直截に言えば while (true) {} でビジーウェイトを期待するのは C++ 的に正しくないと思います。
Contributor
Author
There was a problem hiding this comment.
知りませんでした、ありがとうございます
別の例に書き換えてみます
Contributor
Author
|
ご指摘ありがとうございます。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
レビューお願いします.