Fixed thread_sigpost assuming that every process must have threads
JIRA:
@@ -1348,6 +1348,7 @@ int threads_sigpost(process_t *process, thread_t *thread, int sig)
process->sigpend |= sigbit;
thread = process->threads;
+ if (thread != NULL) {
do {
if (sigbit & ~thread->sigmask) {
if (thread->interruptible)
@@ -1355,8 +1356,16 @@ int threads_sigpost(process_t *process, thread_t *thread, int sig)
break;
}
+ } while ((thread = thread->procnext) != process->threads);
+ }
+ else {
+ /* Case for process without any theads
+ * Might happen during small window between last
+ * thread destroy and process destroy. This process
+ * will end anyway, no point in delivering the signal */
+ hal_spinlockClear(&threads_common.spinlock, &sc);
+ return -ESRCH;
}
- while ((thread = thread->procnext) != process->threads);
}
hal_cpuReschedule(&threads_common.spinlock, &sc);
