
On 09/11/2010 01:32 PM, Boris Schaeling wrote:
Indeed. But as context doesn't support arbitrary file descriptors those must be configured differently anyway.
I'm suggesting that it should. From the library's perspective, there is no difference between configuring the child's file descriptors 0, 1, and 2, and configuring any other file descriptors, at least on POSIX, and given that it is useful for the user, it might as well be exposed. (Of course, on Windows, things are different, but I think you have just as elegant an interface and still allow this flexibility for POSIX while retaining portable syntax.)
Please have a look at <http://svn.boost.org/svn/boost/sandbox/SOC/2010/process/libs/process/example/file_descriptors_setup.cpp>. There are two pipes used to create file descriptors 3 and 4 which should be inherited by the child process. As the pipe stream behavior is used explicitly the user knows if 3 and 4 should be read or write ends of the pipe. The user can pass the information to the pipe stream behavior while the context indeed can't (in this example there is still a boolean value used).
I saw that example, but it hardly seemed like a very good exposition of the convenience provided by the library. (Also, as I alluded to in some of my other example code snippets and as has been discussed a bit by others, I think that using an std::pair as the return value for those type of things is a bad idea. Instead, read_end and write_end, or parent_end and child_end, depending on the situation, should be used.)
[snip]