mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-01-31 17:49:45 +08:00
Ensure we preserve errno in signal handlers
This commit is contained in:
parent
fe6fb23f43
commit
3f3531c819
|
@ -213,8 +213,12 @@ static void fish_signal_handler(int sig, siginfo_t *info, void *context) {
|
|||
UNUSED(info);
|
||||
UNUSED(context);
|
||||
|
||||
// Ensure we preserve errno.
|
||||
const int saved_errno = errno;
|
||||
|
||||
// Check if we are a forked child.
|
||||
if (reraise_if_forked_child(sig)) {
|
||||
errno = saved_errno;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -267,6 +271,7 @@ static void fish_signal_handler(int sig, siginfo_t *info, void *context) {
|
|||
// test, to verify that we behave correctly when receiving lots of irrelevant signals.
|
||||
break;
|
||||
}
|
||||
errno = saved_errno;
|
||||
}
|
||||
|
||||
void signal_reset_handlers() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user