diff --git a/src/io/FileDescriptor.cxx b/src/io/FileDescriptor.cxx index 45c740ee2..08c38ca6c 100644 --- a/src/io/FileDescriptor.cxx +++ b/src/io/FileDescriptor.cxx @@ -213,6 +213,21 @@ FileDescriptor::DisableCloseOnExec() const noexcept fcntl(fd, F_SETFD, old_flags & ~FD_CLOEXEC); } +#ifdef __linux__ + +void +FileDescriptor::SetPipeCapacity(unsigned capacity) const noexcept +{ + /* the canonical type for buffer sizes is "size_t", but since + F_SETPIPE_SZ expects an "int" parameter, "size_t" would + have the wrong size; "unsigned" is always the same size as + "int", but using a signed integer would suggest that + negative values are okay when they're not */ + fcntl(fd, F_SETPIPE_SZ, capacity); +} + +#endif + UniqueFileDescriptor FileDescriptor::Duplicate() const noexcept { diff --git a/src/io/FileDescriptor.hxx b/src/io/FileDescriptor.hxx index edd009440..a77488a4d 100644 --- a/src/io/FileDescriptor.hxx +++ b/src/io/FileDescriptor.hxx @@ -163,6 +163,15 @@ public: */ void DisableCloseOnExec() const noexcept; +#ifdef __linux__ + /** + * Set the capacity of the pipe. + * + * This method ignores errors. + */ + void SetPipeCapacity(unsigned capacity) const noexcept; +#endif + /** * Duplicate this file descriptor. *