diff options
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 |