Skip to content

Conversation

@dayano74
Copy link
Collaborator

@dayano74 dayano74 commented May 5, 2025

外部コマンド実行中にシグナルを受け取った時の処理を追加しました。

./minishellで試してください。

{
(void)signum;
printf("\n");
write(STDOUT_FILENO, "\n", 1);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

writeのほうがシステムコールを呼び出しているだけなので、安全だそうです。

POSIX 標準で「シグナルハンドラ内から呼んで安全」とされる関数群
https://man7.org/linux/man-pages/man7/signal-safety.7.html?utm_source=chatgpt.com

Copy link
Owner

Choose a reason for hiding this comment

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

修正ありがとうございます。
writeで対応する形でOKです。

Copy link
Owner

@cacapon cacapon left a comment

Choose a reason for hiding this comment

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

基本的な挙動はOKです。
ただ、ちょっとbashと挙動が異なる動きを見つけました。
$ sleep 3 | sleep 5 | sleep 4のように複数コマンドがあると改行やQuit (core dumpd)が複数表示されます。

こちらについては別のissueで対応しましょう。

@cacapon cacapon merged commit 1702f00 into main May 5, 2025
2 checks passed
@cacapon cacapon deleted the feature/signal-in-child-process branch May 5, 2025 10:05
@dayano74
Copy link
Collaborator Author

dayano74 commented May 5, 2025

あ、そのパターンは想定していませんでした。イシューで対応わかりました。

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