Skip to content

limit_handles breaks exec() error reporting on POSIX #202

@tomix86

Description

@tomix86

Using limit_handles on POSIX platforms causes internal logic for exec() error reporting to break.
The root cause is that foreach_used_handle on POSIX does not account for executor::_pipe_sink, which is needed for error reporting from child to parent.

A minimal reproducer:

#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <boost/process.hpp>
#include <boost/process/extend.hpp>

namespace bp = boost::process;

TEST(BoostProcessTest, limit_handles_breaks_exec_error_handling) {
	{
		std::error_code ec;
		bp::child{bp::exe = "some_nonexistent_path", ec}.wait();
		EXPECT_EQ(std::errc::no_such_file_or_directory, ec);
	}

	{
		std::error_code ec;
		bp::child{bp::exe = "some_nonexistent_path", ec, bp::limit_handles}.wait();
		// EXPECT_EQ(std::errc::no_such_file_or_directory, ec);
		EXPECT_EQ(std::error_code{}, ec); // Boost.Process bug
	}
}

int main(int argc, char** argv) {
	::testing::InitGoogleTest(&argc, argv);
	return RUN_ALL_TESTS();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions