Can't read and write simultaneously from serial port
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
linux-signed-hwe (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
With linux kernel <=4.15.0-43 I can start reading serial device (TTY) in block mode and write from another process at the same time (simultaneously). After update to 4.15.0-45 I can't.
[Steps to reproduce]
1) Run in terminal:
cat /dev/ttyS0
"cat" must block terminal and wait for data.
2) Run in another terminal:
echo > /dev/ttyS0
Expected:
"cat" continue wait data and not exit.
Actual:
"cat" exit with return code "1" and show error -EAGAIN (-11):
"cat: /dev/ttyS0: Resource temporarily unavailable"
I think it's regression in kernel, due to new ldisc checks in TTY driver. Please see:
git diff Ubuntu-
git diff Ubuntu-
diff --git a/drivers/
index 0fd18f5..48fe8d9 100644
--- a/drivers/
+++ b/drivers/
@@ -340,6 +340,11 @@ int tty_ldisc_
{
int ret;
+ /* Kindly asking blocked readers to release the read side */
+ set_bit(
+ wake_up_
+ wake_up_
+
ret = __tty_ldisc_
if (!ret)
diff --git a/drivers/
index 63c593a..9805ac1 100644
--- a/drivers/
+++ b/drivers/
@@ -2188,7 +2197,7 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file,
- if (file->f_flags & O_NONBLOCK) {
+ if (tty_io_
@@ -2342,7 +2351,7 @@ static ssize_t n_tty_write(struct tty_struct *tty, struct file *file,
}
if (!nr)
- if (file->f_flags & O_NONBLOCK) {
+ if (tty_io_
}
ProblemType: Bug
DistroRelease: Ubuntu 16.04
Package: linux-image-
ProcVersionSign
Uname: Linux 4.15.0-45-generic x86_64
NonfreeKernelMo
ApportVersion: 2.20.1-0ubuntu2.18
Architecture: amd64
CurrentDesktop: MATE
Date: Thu Feb 7 11:42:43 2019
InstallationDate: Installed on 2017-08-01 (554 days ago)
InstallationMedia: Ubuntu 16.04.2 LTS "Xenial Xerus" - Release amd64 (20170215.2)
SourcePackage: linux-signed-hwe
UpgradeStatus: No upgrade log present (probably fresh install)
```
$ bash -c 'sleep 1 && : < /dev/tty & read var' < /dev/tty
bash: line 0: read: read error: 0: Resource temporarily unavailable
```
seems to be related and is possibly the same bug. See https:/ /unix.stackexch ange.com/ questions/ 499422/ bash-how- can-i-run- sudo-n- true-in- the-background- without- interfering- with-r/ 499433? noredirect= 1#comment919635 _499433