diff options
author | Helmut Grohne <helmut@subdivi.de> | 2025-05-06 12:06:56 +0200 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2025-05-06 12:06:56 +0200 |
commit | 87c0d9c6a4f09b96b00ec4796f824dbcfab1ffb3 (patch) | |
tree | bf71f0943f15f5f318b993b170a6c73ce61328dd /linuxnamespaces | |
parent | 1fa71c54e688b10c8c70dfb3cf7136cfb22f2085 (diff) | |
download | python-linuxnamespaces-87c0d9c6a4f09b96b00ec4796f824dbcfab1ffb3.tar.gz |
Diffstat (limited to 'linuxnamespaces')
-rw-r--r-- | linuxnamespaces/filedescriptor.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/linuxnamespaces/filedescriptor.py b/linuxnamespaces/filedescriptor.py index e4eff9b..2cf8442 100644 --- a/linuxnamespaces/filedescriptor.py +++ b/linuxnamespaces/filedescriptor.py @@ -41,6 +41,11 @@ class FileDescriptor(int): """Duplicate the file to the given file descriptor number.""" return FileDescriptor(os.dup2(self, fd2, inheritable)) + @classmethod + def pidfd_open(cls, pid: int, flags: int = 0) -> typing.Self: + """Convenience wrapper for os.pidfd_open.""" + return cls(os.pidfd_open(pid, flags)) + def fileno(self) -> int: """Return self such that it satisfies the HasFileno protocol.""" return self |