interrupted and condStartWaitTime are pushed because syscall's during the signal will clobber them
| 1139 | |
| 1140 | // interrupted and condStartWaitTime are pushed because syscall's during the signal will clobber them |
| 1141 | void KThread::runSignal(U32 signal, U32 trapNo, U32 errorNo) { |
| 1142 | KSigAction* action = &this->process->sigActions[signal]; |
| 1143 | if (action->handlerAndSigAction==K_SIG_DFL) { |
| 1144 | //klog("%x/%x default runSignal %d", this->id, this->process->id, signal); |
| 1145 | if (signal == K_SIGURG || signal == K_SIGCONT || signal == K_SIGCHLD || signal == K_SIGWINCH) { |
| 1146 | // ignored by default |
| 1147 | } else { |
| 1148 | process->signal(K_SIGKILL); |
| 1149 | } |
| 1150 | } else if (action->handlerAndSigAction != K_SIG_IGN) { |
| 1151 | U32 context = 0; |
| 1152 | U32 address = 0; |
| 1153 | U32 stack = this->cpu->reg[4].u32; |
| 1154 | U32 interrupted = 0; |
| 1155 | bool altStack = (action->flags & K_SA_ONSTACK) != 0; |
| 1156 | ChangeThread c(this); |
| 1157 | |
| 1158 | cpu->fillFlags(); |
| 1159 | |
| 1160 | #ifdef LOG_OPS |
| 1161 | klog("runSignal %d", signal); |
| 1162 | klog(" before signal %.8X EAX=%.8X ECX=%.8X EDX=%.8X EBX=%.8X ESP=%.8X EBP=%.8X ESI=%.8X EDI=%.8X fs=%d(%X) fs18=%X", cpu->eip.u32, cpu->reg[0].u32, cpu->reg[1].u32, cpu->reg[2].u32, cpu->reg[3].u32, cpu->reg[4].u32, cpu->reg[5].u32, cpu->reg[6].u32, cpu->reg[7].u32, cpu->seg[4].value, cpu->seg[4].address, cpu->seg[4].address?readd(cpu->seg[4].address+0x18):0); |
| 1163 | #endif |
| 1164 | this->inSigMask=action->mask | this->sigMask; |
| 1165 | if (action->flags & K_SA_RESETHAND) { |
| 1166 | action->handlerAndSigAction=K_SIG_DFL; |
| 1167 | } else if (!(action->flags & K_SA_NODEFER)) { |
| 1168 | this->inSigMask|= (U64)1 << (signal-1); |
| 1169 | } |
| 1170 | #ifndef BOXEDWINE_MULTI_THREADED |
| 1171 | if (this->waitingCond) { |
| 1172 | if (!(action->flags & K_SA_RESTART)) |
| 1173 | interrupted = 1; |
| 1174 | this->waitingCond->signalAll(); // this will make sure it gets cleaned up properly |
| 1175 | } |
| 1176 | #endif |
| 1177 | // move to front of the queue |
| 1178 | #ifndef BOXEDWINE_MULTI_THREADED |
| 1179 | unscheduleThread(this); |
| 1180 | scheduleThread(this); |
| 1181 | #endif |
| 1182 | if (altStack) { |
| 1183 | context = this->alternateStack + this->alternateStackSize - CONTEXT_SIZE; |
| 1184 | } else { |
| 1185 | context = this->cpu->seg[SS].address + (ESP & this->cpu->stackMask) - CONTEXT_SIZE; |
| 1186 | } |
| 1187 | writeToContext(this, stack, context, altStack, trapNo, errorNo); |
| 1188 | |
| 1189 | this->cpu->stackMask = 0xFFFFFFFF; |
| 1190 | this->cpu->stackNotMask = 0; |
| 1191 | this->cpu->seg[SS].address = 0; |
| 1192 | this->cpu->reg[4].u32 = context; |
| 1193 | |
| 1194 | this->cpu->reg[4].u32 &= ~15; |
| 1195 | if (action->flags & K_SA_SIGINFO) { |
| 1196 | this->cpu->reg[4].u32-=INFO_SIZE; |
| 1197 | address = this->cpu->reg[4].u32; |
| 1198 | for (U32 i=0;i<K_SIG_INFO_SIZE;i++) { |
no test coverage detected