if you're in bpfclose or tun/tap close, you're the last one out. this means that there shouldn't be anything else in poll/select/kevent/etc because you're the last one out.
from what i can tell, tun and bpf are the only drivers that do this, and i dont think they need to. ok? Index: bpf.c =================================================================== RCS file: /cvs/src/sys/net/bpf.c,v retrieving revision 1.209 diff -u -p -r1.209 bpf.c --- bpf.c 13 Jan 2022 14:15:27 -0000 1.209 +++ bpf.c 16 Jan 2022 04:33:02 -0000 @@ -401,7 +401,6 @@ bpfclose(dev_t dev, int flag, int mode, d = bpfilter_lookup(minor(dev)); mtx_enter(&d->bd_mtx); bpf_detachd(d); - bpf_wakeup(d); LIST_REMOVE(d, bd_list); mtx_leave(&d->bd_mtx); bpf_put(d); Index: if_tun.c =================================================================== RCS file: /cvs/src/sys/net/if_tun.c,v retrieving revision 1.231 diff -u -p -r1.231 if_tun.c --- if_tun.c 9 Mar 2021 20:05:14 -0000 1.231 +++ if_tun.c 16 Jan 2022 04:33:02 -0000 @@ -460,7 +460,6 @@ tun_dev_close(dev_t dev, struct proc *p) ifq_purge(&ifp->if_snd); CLR(sc->sc_flags, TUN_ASYNC); - selwakeup(&sc->sc_rsel); sigio_free(&sc->sc_sigio); if (!ISSET(sc->sc_flags, TUN_DEAD)) {