Skip to content

add new pages sig_dfl,sig_err,sig_ign#1586

Open
K10-K10 wants to merge 5 commits intomasterfrom
feat/csignal
Open

add new pages sig_dfl,sig_err,sig_ign#1586
K10-K10 wants to merge 5 commits intomasterfrom
feat/csignal

Conversation

@K10-K10
Copy link
Contributor

@K10-K10 K10-K10 commented Feb 26, 2026

レビューお願いします.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 26, 2026

プレビュー (HTML) (更新時刻: 2026-02-28 17:38:58 JST)

  • Commit: e96f3f2
  • プレビューの生成には時間がかかります (3~5分)。進捗状況はこちらをご確認ください。

変更記事一覧

789件の記事が変更されました。多いため一部を表示しています。完全なリストについてはこちらをご参照ください。

(ファイル一覧)

※ソース (.md) に直接変更のあった記事を列挙しています。グローバル修飾や変換規則の変更による変化は考慮していません。

## 概要
`signal`関数に渡される引数として、シグナルに対するデフォルトの処理を指定するマクロ。

シグナル受信時に`signal`関数で`SIG_DFL`が指定されている場合、そのシグナルに対する実装定義のデフォルト処理が実行される。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

これは用途を記載したほうがいい気がしました。
シグナルハンドラーの登録を解除するものですよね。
サンプルコードもそのような用途を説明するものだとよいかと思います。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

変更しました.


void signal_handler(int)
{
std::cout << "Custom handler\n";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

シグナルハンドラでのcoutの使用は未定義動作なので、別なサンプルにするか、サンプルのためこうしてるが実際にはやってはいけないとコメントするかするのがよさそうです

std::signal(SIGINT, SIG_DFL);
std::cout << "Press Ctrl+C\n";
// ここで Ctrl+C を押すと、デフォルト動作
while (true) {
Copy link
Member

@akinomyoga akinomyoga Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

これは最適化で消滅する可能性があるのでは。

cf [intro.progress]

それとも何か最近規格で動きがあったりしますか。巷ではUBとされていたのがP2809R3 で修正されて、消滅してよくなって、さらに P3881R0 (未採択) で何か議論しているみたいですが。

Copy link
Member

@akinomyoga akinomyoga Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

上は迂遠な書き方になってしまいましたが、直截に言えば while (true) {} でビジーウェイトを期待するのは C++ 的に正しくないと思います。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

知りませんでした、ありがとうございます
別の例に書き換えてみます

@K10-K10
Copy link
Contributor Author

K10-K10 commented Feb 28, 2026

ご指摘ありがとうございます。
修正したので、ご確認いただけますか。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants