Skip to content

Commit

Permalink
set_pipe_capacity_max work locally.
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverPlate3 committed Jun 28, 2023
1 parent 84f3303 commit f778a9e
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions include/boost/process/detail/posix/basic_pipe.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
#include <fcntl.h>
#include <memory>

#if !(defined(__NetBSD__) || defined(__FreeBSD__) || defined(__APPLE__) || defined(__MACH__))
#include <fstream>
#include <string>
#endif


namespace boost { namespace process { namespace detail { namespace posix {


Expand Down Expand Up @@ -121,8 +127,27 @@ class basic_pipe
_sink = -1;
}

#if !(defined(__NetBSD__) || defined(__FreeBSD__) || defined(__APPLE__) || defined(__MACH__))
int_type set_pipe_capacity(int_type capacity)
#if !(defined(__NetBSD__) || defined(__FreeBSD__) || defined(__APPLE__) || defined(__MACH__))

int_type set_pipe_capacity_max()
{
std::ifstream file("/proc/sys/fs/pipe-max-size");
std::string content;
if(file.is_open())
{
std::getline(file, content);
file.close();
}
else
{
return -1;
}

int_type max_capacity = std::stoi(content);
return set_pipe_capacity(max_capacity);
}

int_type set_pipe_capacity(int_type capacity)
{
if (!is_open())
{
Expand All @@ -141,7 +166,8 @@ class basic_pipe

return return_value;
}
#endif

#endif
};

template<class CharT, class Traits>
Expand Down

0 comments on commit f778a9e

Please sign in to comment.