* Run a thread that (among whatever else it does) makes system calls, * then checks for IsExitRequested() after making any blocking system * calls. * * We first set it up with a per-thread signal mask that blocks all * but SIG_THREAD_EXIT, or if the only blocking system call it makes * is pselect()/ppoll(), blocks all signals entirely. */
| 99 | * is pselect()/ppoll(), blocks all signals entirely. |
| 100 | */ |
| 101 | void SyscallThread::RunInThread(SyscallThread *syscaller, bool reliable) { |
| 102 | // Block the appropriate set of signals. |
| 103 | PthreadSetSigmask(GetMask(reliable)); |
| 104 | |
| 105 | // Note that we're now ready to act upon SIG_THREAD_EXIT, i.e., |
| 106 | // we have the right signal mask established. This is really |
| 107 | // just for debug - we have to be able to act on it early. |
| 108 | syscaller->state_ = SyscallThread::ThreadState::kReady; |
| 109 | |
| 110 | // Run the user's code. Note that it's possible that we were told |
| 111 | // to exit already, e.g., before we finished setting the signal mask; |
| 112 | // in this case, do NOT run the user's code (it might block forever, |
| 113 | // if pfuncs is true). |
| 114 | if (!syscaller->exit_requested_) { |
| 115 | syscaller->Run(); |
| 116 | } |
| 117 | |
| 118 | // We're done; remark on this and terminate (by returning). |
| 119 | syscaller->state_ = SyscallThread::ThreadState::kDone; |
| 120 | } |
| 121 | |
| 122 | /* |
| 123 | * Send the "please exit" signal that interrupts a system call |
nothing calls this directly
no test coverage detected