diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2024-11-21 12:48:03 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2024-11-21 12:48:03 +0000 |
commit | 8b10f68372fd0e881086c4872590652916a3b0d9 (patch) | |
tree | 7c370fba8b9adecb103a278e57a97069ec48a5bc /lib | |
parent | d1bd310590c1401a0ae6ec07930291c19c8ba763 (diff) |
Refine imsg_forward(), do not close fd, just don't forward it.
imsg_free() will close the unclaimed fds at the end.
OK tb@
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libutil/imsg.c | 7 | ||||
-rw-r--r-- | lib/libutil/imsg_init.3 | 11 |
2 files changed, 9 insertions, 9 deletions
diff --git a/lib/libutil/imsg.c b/lib/libutil/imsg.c index c24967a424c..bc9bc590f68 100644 --- a/lib/libutil/imsg.c +++ b/lib/libutil/imsg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: imsg.c,v 1.24 2024/11/21 12:47:27 claudio Exp $ */ +/* $OpenBSD: imsg.c,v 1.25 2024/11/21 12:48:02 claudio Exp $ */ /* * Copyright (c) 2023 Claudio Jeker <claudio@openbsd.org> @@ -324,11 +324,6 @@ imsg_forward(struct imsgbuf *imsgbuf, struct imsg *msg) struct ibuf *wbuf; size_t len = 0; - if (msg->fd != -1) { - close(msg->fd); - msg->fd = -1; - } - if (msg->buf != NULL) { ibuf_rewind(msg->buf); len = ibuf_size(msg->buf); diff --git a/lib/libutil/imsg_init.3 b/lib/libutil/imsg_init.3 index d61610151a3..f1ade4ab40d 100644 --- a/lib/libutil/imsg_init.3 +++ b/lib/libutil/imsg_init.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: imsg_init.3,v 1.33 2023/12/29 11:48:47 claudio Exp $ +.\" $OpenBSD: imsg_init.3,v 1.34 2024/11/21 12:48:02 claudio Exp $ .\" .\" Copyright (c) 2023 Claudio Jeker <claudio@openbsd.org> .\" Copyright (c) 2010 Nicholas Marriott <nicm@openbsd.org> @@ -15,7 +15,7 @@ .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING .\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: December 29 2023 $ +.Dd $Mdocdate: November 21 2024 $ .Dt IMSG_INIT 3 .Os .Sh NAME @@ -224,7 +224,10 @@ forwards a just received .Fa msg unaltered on .Fa imsgbuf . -Any attached file descriptor is closed. +File descriptors are not forwarded by this function. +It is possible to call +.Fn imsg_forward +more than once per message. .Pp .Fn imsg_flush calls @@ -280,6 +283,8 @@ returns 0. .Fn imsg_get_fd returns the file descriptor and passes the responsibility to track the descriptor back to the program. +Unclaimed file descriptors are closed by +.Fn imsg_free . .Pp .Fn imsg_get_data and |