The branch main has been updated by markj:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=be6c405c4d34366618ab55e3a730090f6c672968

commit be6c405c4d34366618ab55e3a730090f6c672968
Author:     Ricardo Branco <rbra...@suse.de>
AuthorDate: 2025-05-09 21:43:51 +0000
Commit:     Mark Johnston <ma...@freebsd.org>
CommitDate: 2025-07-06 23:08:28 +0000

    socket: Add MSG_CMSG_CLOFORK flag
    
    Reviewed by:    kib
    MFC after:      1 month
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/1698
---
 sys/kern/uipc_usrreq.c | 3 ++-
 sys/sys/socket.h       | 3 +++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c
index 72bd0246db11..0056dac65c7d 100644
--- a/sys/kern/uipc_usrreq.c
+++ b/sys/kern/uipc_usrreq.c
@@ -3463,7 +3463,8 @@ unp_externalize(struct mbuf *control, struct mbuf 
**controlp, int flags)
 
        UNP_LINK_UNLOCK_ASSERT();
 
-       fdflags = (flags & MSG_CMSG_CLOEXEC) ? O_CLOEXEC : 0;
+       fdflags = ((flags & MSG_CMSG_CLOEXEC) ? O_CLOEXEC : 0) |
+           ((flags & MSG_CMSG_CLOFORK) ? O_CLOFORK : 0);
 
        error = 0;
        if (controlp != NULL) /* controlp == NULL => free control messages */
diff --git a/sys/sys/socket.h b/sys/sys/socket.h
index 8db981c9747c..cdd4fa3b4b89 100644
--- a/sys/sys/socket.h
+++ b/sys/sys/socket.h
@@ -479,6 +479,9 @@ struct msghdr {
 #define        MSG_MORETOCOME   0x00100000     /* additional data pending */
 #define        MSG_TLSAPPDATA   0x00200000     /* do not soreceive() alert 
rec. (TLS) */
 #endif
+#if __BSD_VISIBLE
+#define        MSG_CMSG_CLOFORK 0x00400000     /* make received fds 
close-on-fork */
+#endif
 
 /*
  * Header for ancillary data objects in msg_control buffer.

Reply via email to