MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / signal

Method signal

source/kernel/kprocess.cpp:2724–2767  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2722}
2723
2724U32 KProcess::signal(U32 signal) {
2725 if (signal == K_SIGKILL) {
2726 KThread* currentThread = KThread::currentThread();
2727 if (currentThread->process->id != id) {
2728 currentThread = nullptr;
2729 }
2730 this->killAllThreads(currentThread);
2731 if (currentThread) {
2732 terminateCurrentThread(currentThread);
2733 }
2734 return 0;
2735 }
2736 {
2737 KThread* foundThread = nullptr;
2738 {
2739 BOXEDWINE_CRITICAL_SECTION_WITH_MUTEX(threadsMutex);
2740 for (auto& t : this->threads) {
2741 KThread* thread = t.value;
2742 BOXEDWINE_CRITICAL_SECTION_WITH_CONDITION(thread->sigWaitCond);
2743 if (thread->sigWaitMask & signal) {
2744 thread->foundWaitSignal = signal;
2745 BOXEDWINE_CONDITION_SIGNAL(thread->sigWaitCond);
2746 return 0;
2747 }
2748 }
2749 for (auto& t : this->threads) {
2750 KThread* thread = t.value;
2751
2752 if (((U64)1 << (signal - 1)) & ~(thread->inSignal ? thread->inSigMask : thread->sigMask)) {
2753 foundThread = thread;
2754 break;
2755 }
2756 }
2757 }
2758 if (foundThread) {
2759 return foundThread->signal(signal, false);
2760 }
2761 }
2762 // didn't find a thread that could handle it
2763 BOXEDWINE_CRITICAL_SECTION_WITH_MUTEX(this->pendingSignalsMutex);
2764 this->pendingSignals |= ((U64)1 << (signal-1));
2765 this->signalFd(nullptr, signal);
2766 return 0;
2767}
2768
2769void KProcess::signalFd(KThread* thread, U32 signal) {
2770 BOXEDWINE_CRITICAL_SECTION_WITH_MUTEX(fdsMutex);

Callers

nothing calls this directly

Calls 3

killAllThreadsMethod · 0.95
signalFdMethod · 0.95
terminateCurrentThreadFunction · 0.70

Tested by

no test coverage detected