From c5dc368cd41232c11e3ab9e97c84c8eabe5e4f75 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 23 Nov 2024 08:38:16 +0100 Subject: [PATCH] net/SocketDescriptor: add GetPeerPidfd() --- src/net/SocketDescriptor.hxx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/net/SocketDescriptor.hxx b/src/net/SocketDescriptor.hxx index 1b2f0c0..1f0621c 100644 --- a/src/net/SocketDescriptor.hxx +++ b/src/net/SocketDescriptor.hxx @@ -25,6 +25,7 @@ class StaticSocketAddress; class IPv4Address; class IPv6Address; class UniqueSocketDescriptor; +class UniqueFileDescriptor; /** * An OO wrapper for a Berkeley or WinSock socket descriptor. @@ -229,6 +230,16 @@ public: struct ucred GetPeerCredentials() const noexcept; #endif +#ifdef __linux__ + /** + * Get a pidfd for the peer process. Returns an undefined + * instance on error (with errno set). + * + * Requires Linux 6.5. + */ + UniqueFileDescriptor GetPeerPidfd() const noexcept; +#endif // __linux__ + bool SetOption(int level, int name, const void *value, std::size_t size) const noexcept;