Author: kib Date: Sun Oct 4 16:33:42 2020 New Revision: 366429 URL: https://svnweb.freebsd.org/changeset/base/366429
Log: 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 Modified: head/sys/kern/kern_sig.c head/sys/sys/signalvar.h Modified: head/sys/kern/kern_sig.c ============================================================================== --- head/sys/kern/kern_sig.c Sun Oct 4 16:30:05 2020 (r366428) +++ head/sys/kern/kern_sig.c Sun Oct 4 16:33:42 2020 (r366429) @@ -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) { Modified: head/sys/sys/signalvar.h ============================================================================== --- head/sys/sys/signalvar.h Sun Oct 4 16:30:05 2020 (r366428) +++ head/sys/sys/signalvar.h Sun Oct 4 16:33:42 2020 (r366429) @@ -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); _______________________________________________ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"