[PATCH 3/4] um: chan: Restore blocking mode upon exit
Richard Weinberger
richard at nod.at
Sat Jan 1 13:58:09 PST 2022
Make sure that O_NONBLOCK is cleared upon exit if UML sets it.
Otherwise stdin/out behaves strange after UML terminates.
Signed-off-by: Richard Weinberger <richard at nod.at>
---
arch/um/drivers/chan.h | 1 +
arch/um/drivers/chan_kern.c | 3 +++
2 files changed, 4 insertions(+)
diff --git a/arch/um/drivers/chan.h b/arch/um/drivers/chan.h
index c37cc4f26f91..6b8c462f146e 100644
--- a/arch/um/drivers/chan.h
+++ b/arch/um/drivers/chan.h
@@ -22,6 +22,7 @@ struct chan {
unsigned int output:1;
unsigned int opened:1;
unsigned int enabled:1;
+ unsigned int fd_blocking:1;
int fd;
const struct chan_ops *ops;
void *data;
diff --git a/arch/um/drivers/chan_kern.c b/arch/um/drivers/chan_kern.c
index 86be115b5890..6d512589fa50 100644
--- a/arch/um/drivers/chan_kern.c
+++ b/arch/um/drivers/chan_kern.c
@@ -102,6 +102,7 @@ static int open_one_chan(struct chan *chan)
}
chan->fd = fd;
+ chan->fd_blocking = ret;
chan->opened = 1;
return 0;
@@ -223,6 +224,8 @@ static void close_one_chan(struct chan *chan, int delay_free_irq)
if (chan->ops->close != NULL)
(*chan->ops->close)(chan->fd, chan->data);
+ os_set_fd_block(chan->fd, chan->fd_blocking);
+
chan->opened = 0;
chan->fd = -1;
}
--
2.26.2
More information about the linux-um
mailing list