diff --git a/kernel/src/sys/waitpid.cpp b/kernel/src/sys/waitpid.cpp index 3ad215c2..f533768f 100644 --- a/kernel/src/sys/waitpid.cpp +++ b/kernel/src/sys/waitpid.cpp @@ -26,7 +26,7 @@ Result sys_waitpid(Registers* regs, SyscallArgs args) wait_for_child: if (!target->dead()) kernel_wait(pid); - if (current->interrupted && current->pending_signal() != SIGCHLD) + if (current->interrupted && (current->pending_signal_count() > 1 || current->pending_signal() != SIGCHLD)) { kdbgln("signal: waitpid interrupted by signal"); if (current->will_ignore_pending_signal()) @@ -50,7 +50,7 @@ Result sys_waitpid(Registers* regs, SyscallArgs args) wait_for_any_child: kernel_wait(pid); - if (current->interrupted && current->pending_signal() != SIGCHLD) + if (current->interrupted && (current->pending_signal_count() > 1 || current->pending_signal() != SIGCHLD)) { kdbgln("signal: waitpid interrupted by signal"); if (current->will_ignore_pending_signal()) diff --git a/kernel/src/thread/Thread.cpp b/kernel/src/thread/Thread.cpp index 967c8dc5..74771917 100644 --- a/kernel/src/thread/Thread.cpp +++ b/kernel/src/thread/Thread.cpp @@ -277,6 +277,16 @@ void Thread::process_pending_signals(Registers* current_regs) } } +int Thread::pending_signal_count() +{ + int result = 0; + for (int i = 0; i < NSIG; i++) + { + if (pending_signals.get(i)) { result++; } + } + return result; +} + int Thread::pending_signal() { for (int i = 0; i < NSIG; i++) diff --git a/kernel/src/thread/Thread.h b/kernel/src/thread/Thread.h index 5bec29ea..082734e3 100644 --- a/kernel/src/thread/Thread.h +++ b/kernel/src/thread/Thread.h @@ -208,6 +208,7 @@ struct Thread : public LinkedListNode void process_pending_signals(Registers* current_regs); + int pending_signal_count(); int pending_signal(); bool will_ignore_pending_signal();