MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ttydev_poll

Function ttydev_poll

freebsd/kern/tty.c:647–682  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

645}
646
647static int
648ttydev_poll(struct cdev *dev, int events, struct thread *td)
649{
650 struct tty *tp = dev->si_drv1;
651 int error, revents = 0;
652
653 error = ttydev_enter(tp);
654 if (error)
655 return ((events & (POLLIN|POLLRDNORM)) | POLLHUP);
656
657 if (events & (POLLIN|POLLRDNORM)) {
658 /* See if we can read something. */
659 if (ttydisc_read_poll(tp) > 0)
660 revents |= events & (POLLIN|POLLRDNORM);
661 }
662
663 if (tp->t_flags & TF_ZOMBIE) {
664 /* Hangup flag on zombie state. */
665 revents |= POLLHUP;
666 } else if (events & (POLLOUT|POLLWRNORM)) {
667 /* See if we can write something. */
668 if (ttydisc_write_poll(tp) > 0)
669 revents |= events & (POLLOUT|POLLWRNORM);
670 }
671
672 if (revents == 0) {
673 if (events & (POLLIN|POLLRDNORM))
674 selrecord(td, &tp->t_inpoll);
675 if (events & (POLLOUT|POLLWRNORM))
676 selrecord(td, &tp->t_outpoll);
677 }
678
679 tty_unlock(tp);
680
681 return (revents);
682}
683
684static int
685ttydev_mmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr,

Callers

nothing calls this directly

Calls 4

ttydev_enterFunction · 0.85
ttydisc_read_pollFunction · 0.85
ttydisc_write_pollFunction · 0.85
selrecordFunction · 0.85

Tested by

no test coverage detected