00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00019 #ifndef BOOST_PROCESS_POSIX_OPERATIONS_HPP
00020 #define BOOST_PROCESS_POSIX_OPERATIONS_HPP
00021
00022 #include <boost/process/posix_child.hpp>
00023 #include <boost/process/posix_context.hpp>
00024 #include <boost/process/stream_behavior.hpp>
00025 #include <boost/process/detail/stream_info.hpp>
00026 #include <boost/process/detail/posix_ops.hpp>
00027 #include <sys/types.h>
00028
00029 namespace boost {
00030 namespace process {
00031
00042 template <class Executable, class Arguments, class Posix_Context>
00043 inline posix_child posix_launch(const Executable &exe, const Arguments &args, const Posix_Context &ctx)
00044 {
00045 detail::info_map input_info;
00046 for (behavior_map::const_iterator it = ctx.input_behavior.begin(); it != ctx.input_behavior.end(); ++it)
00047 {
00048 if (it->second.get_type() != stream_behavior::close)
00049 {
00050 detail::stream_info si = detail::stream_info(it->second, false);
00051 input_info.insert(detail::info_map::value_type(it->first, si));
00052 }
00053 }
00054
00055 detail::info_map output_info;
00056 for (behavior_map::const_iterator it = ctx.output_behavior.begin(); it != ctx.output_behavior.end(); ++it)
00057 {
00058 if (it->second.get_type() != stream_behavior::close)
00059 {
00060 detail::stream_info si = detail::stream_info(it->second, true);
00061 output_info.insert(detail::info_map::value_type(it->first, si));
00062 }
00063 }
00064
00065 detail::posix_setup s;
00066 s.work_directory = ctx.work_directory;
00067 s.uid = ctx.uid;
00068 s.euid = ctx.euid;
00069 s.gid = ctx.gid;
00070 s.egid = ctx.egid;
00071 s.chroot = ctx.chroot;
00072
00073 pid_t pid = detail::posix_start(exe, args, ctx.environment, input_info, output_info, s);
00074
00075 return posix_child(pid, input_info, output_info);
00076 }
00077
00078 }
00079 }
00080
00081 #endif