Add sig_intr(9).

It gives the answer would the thread sleep according to current state
of signals and suspensions.  Of course the answer is racy and allows
for false-negatives (no sleep when signal is delivered after process
lock is dropped).  Also the answer might change due to signal
rescheduling among threads in multi-threaded process.

Still it is the best approximation I can provide, to answering the
question was the thread interrupted.

Reviewed by:	markj
Tested by:	pho, rmacklem
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D26628
This commit is contained in:
kib 2020-10-04 16:33:42 +00:00
parent 488a29c7f2
commit e42c608b41
2 changed files with 19 additions and 0 deletions

View File

@ -3204,6 +3204,24 @@ sig_ast_needsigchk(struct thread *td)
return (ret);
}
int
sig_intr(void)
{
struct thread *td;
struct proc *p;
int ret;
td = curthread;
p = td->td_proc;
PROC_LOCK(p);
ret = sig_ast_checksusp(td);
if (ret == 0)
ret = sig_ast_needsigchk(td);
PROC_UNLOCK(p);
return (ret);
}
void
proc_wkilled(struct proc *p)
{

View File

@ -408,6 +408,7 @@ int sig_ffs(sigset_t *set);
void sigfastblock_clear(struct thread *td);
void sigfastblock_fetch(struct thread *td);
void sigfastblock_setpend(struct thread *td, bool resched);
int sig_intr(void);
void siginit(struct proc *p);
void signotify(struct thread *td);
void sigqueue_delete(struct sigqueue *queue, int sig);