FreeBSD Bugzilla – Attachment 236843 Details for
Bug 266627
stty -f <file> should be non-blocking
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
tty: do not wait for job control when doing mod ioctl on non-blocking tty fd
1.patch (text/plain), 2.07 KB, created by
Konstantin Belousov
on 2022-09-26 21:25:12 UTC
(
hide
)
Description:
tty: do not wait for job control when doing mod ioctl on non-blocking tty fd
Filename:
MIME Type:
Creator:
Konstantin Belousov
Created:
2022-09-26 21:25:12 UTC
Size:
2.07 KB
patch
obsolete
>commit 55cdfcc704698cc2d2e6f7b2a6fc9b5aeb7712ed >Author: Konstantin Belousov <kib@FreeBSD.org> >Date: Mon Sep 26 22:32:04 2022 +0300 > > tty: do not wait for job control when doing mod ioctl on non-blocking tty fd > > return EAGAIN instead. > > PR: 266627 > >diff --git a/sys/kern/tty.c b/sys/kern/tty.c >index 5fa7b3dc7525..a19d94e14306 100644 >--- a/sys/kern/tty.c >+++ b/sys/kern/tty.c >@@ -420,12 +420,16 @@ tty_is_ctty(struct tty *tp, struct proc *p) > } > > int >-tty_wait_background(struct tty *tp, struct thread *td, int sig) >+tty_wait_background(struct tty *tp, struct thread *td, int sigx) > { > struct proc *p; > struct pgrp *pg; > ksiginfo_t ksi; >- int error; >+ int error, sig; >+ bool nonblock; >+ >+ sig = sigx & ~TTY_WB_NONBLOCK; >+ nonblock = (sigx & TTY_WB_NONBLOCK) != 0; > > MPASS(sig == SIGTTIN || sig == SIGTTOU); > tty_assert_locked(tp); >@@ -479,6 +483,11 @@ tty_wait_background(struct tty *tp, struct thread *td, int sig) > } > PROC_UNLOCK(p); > >+ if (nonblock) { >+ PGRP_UNLOCK(pg); >+ return (EWOULDBLOCK); >+ } >+ > /* > * Send the signal and sleep until we're the new > * foreground process group. >@@ -606,7 +615,8 @@ ttydev_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag, > * If the ioctl() causes the TTY to be modified, let it > * wait in the background. > */ >- error = tty_wait_background(tp, curthread, SIGTTOU); >+ error = tty_wait_background(tp, curthread, SIGTTOU | >+ ((fflag & O_NONBLOCK) != 0 ? TTY_WB_NONBLOCK : 0)); > if (error) > goto done; > } >diff --git a/sys/sys/tty.h b/sys/sys/tty.h >index 4ee76b343c3a..5853ef4c34c2 100644 >--- a/sys/sys/tty.h >+++ b/sys/sys/tty.h >@@ -191,7 +191,9 @@ int tty_makedevf(struct tty *tp, struct ucred *cred, int flags, > /* Signalling processes. */ > void tty_signal_sessleader(struct tty *tp, int signal); > void tty_signal_pgrp(struct tty *tp, int signal); >+ > /* Waking up readers/writers. */ >+#define TTY_WB_NONBLOCK 0x80000000 > int tty_wait(struct tty *tp, struct cv *cv); > int tty_wait_background(struct tty *tp, struct thread *td, int sig); > int tty_timedwait(struct tty *tp, struct cv *cv, int timo);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 266627
:
236840
|
236841
| 236843 |
236847