Skip to content

Commit

Permalink
Merge pull request #1 from boostorg/develop
Browse files Browse the repository at this point in the history
Bugfixes 1.64 beta
  • Loading branch information
klemens-morgenstern committed Mar 23, 2017
2 parents 6b433c8 + 04063ee commit 477a60e
Show file tree
Hide file tree
Showing 72 changed files with 1,836 additions and 1,631 deletions.
44 changes: 22 additions & 22 deletions doc/faq.qbk
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[section:faq Frequently Asked Questions]

[section:dead_lock Why does this produce a deadlock?]

Now let's revisit our c++filt example and we will put in an obvious mistake.
This might however be not as obvious for more complex applications.

```
vector<string> demangle(vector<string> in)
{
Expand All @@ -26,62 +26,62 @@ vector<string> demangle(vector<string> in)
We switched the read and write operation up, so that's causing a dead-lock.
This locks immediately. This is because `c++filt` expects input, before
outputting any data. The launching process on the other hand wait's for it's output.

[endsect]

[section:closep Why does the pipe not close?]

Now for another example, which might look correct, let's consider you want
to use `ls` to read the current directory.

```
ipstream is;
child c("ls", std_out > is);

std::string file;
while (is >> file)
cout << "File: " << file << endl;

```

This will also deadlock, because the pipe does not close when the subprocess exits.
So the `ipstream` will still look for data even though the process has ended.

[note It is not possible to use automatically pipe-closing in this library, because
a pipe might be a file-handle (as for async pipes on windows).]

But, since pipes are buffered, you might get incomplete data if you do this:

```
ipstream is;
child c("ls", std_out > is);

std::string file;
while (c.running())
{
is >> file;
cout << "File: " << file << endl;
}
```

It is therefore highly recommended that you use the asynchronous api if you are
not absolutely sure how the output will look.

[endsect]

[section:wchar_t When will the codecvt be used?]

Since windows does not use UTF-8 it is sometimes unavoidable to use the `wchar_t` version of the WinApi.
To keep this library consistent it provides `wchar_t` support on posix also.

Since the posix api is purely `char` every `wchar_t` based type will be converted into `char`.

Windows on the other hand is more selective; the default is to use `char`,
but if any parameter requires `wchar_t`, everything will be converted to `wchar_t`.
This also includes `boost::filesystem::path`. Additionally, if the system does not provide
the `char` api (as is the case with Windows CE) everything will also be converted.


[endsect]

[endsect]
4 changes: 2 additions & 2 deletions include/boost/process/async_system.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct async_system_handler : ::boost::process::detail::api::async_handler


template<typename Exec>
void on_error(Exec & exec, const std::error_code & ec)
void on_error(Exec&, const std::error_code & ec)
{
#if defined(BOOST_POSIX_API)
errored = true;
Expand All @@ -78,7 +78,7 @@ struct async_system_handler : ::boost::process::detail::api::async_handler
}

template<typename Executor>
std::function<void(int, const std::error_code&)> on_exit_handler(Executor & exec)
std::function<void(int, const std::error_code&)> on_exit_handler(Executor&)
{
#if defined(BOOST_POSIX_API)
if (errored)
Expand Down
60 changes: 30 additions & 30 deletions include/boost/process/cmd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)


#ifndef BOOST_PROCESS_DETAIL_CMD_LINE_HPP
#define BOOST_PROCESS_DETAIL_CMD_LINE_HPP


#include <boost/detail/winapi/config.hpp>
#include <boost/process/detail/config.hpp>
#include <boost/process/detail/handler_base.hpp>
#include <boost/process/detail/traits/cmd_or_exe.hpp>
#include <boost/process/detail/traits/wchar_t.hpp>


#if defined(BOOST_POSIX_API)
#include <boost/process/detail/posix/cmd.hpp>
#elif defined(BOOST_WINDOWS_API)
#include <boost/process/detail/windows/cmd.hpp>
#endif


/** \file boost/process/cmd.hpp
*
* This header provides the \xmlonly <globalname alt="boost::process::cmd">cmd</globalname>\endxmlonly property.
Expand All @@ -37,14 +37,14 @@ namespace boost {
</programlisting>
\endxmlonly
*/


namespace boost { namespace process { namespace detail {




struct cmd_
{
constexpr cmd_() {}


template<typename Char>
inline api::cmd_setter_<Char> operator()(const Char *s) const
{
Expand All @@ -55,7 +55,7 @@ struct cmd_
{
return api::cmd_setter_<Char>(s);
}


template<typename Char>
inline api::cmd_setter_<Char> operator()(const std::basic_string<Char> &s) const
{
Expand All @@ -67,11 +67,11 @@ struct cmd_
return api::cmd_setter_<Char>(s);
}
};


template<> struct is_wchar_t<api::cmd_setter_<wchar_t>> : std::true_type {};






template<>
struct char_converter<char, api::cmd_setter_<wchar_t>>
{
Expand All @@ -80,7 +80,7 @@ struct char_converter<char, api::cmd_setter_<wchar_t>>
return { ::boost::process::detail::convert(in.str()) };
}
};


template<>
struct char_converter<wchar_t, api::cmd_setter_<char>>
{
Expand All @@ -89,34 +89,34 @@ struct char_converter<wchar_t, api::cmd_setter_<char>>
return { ::boost::process::detail::convert(in.str()) };
}
};












}




/** The cmd property allows to explicitly set commands for the execution.
The overload form applies when only one string is passed to a launching function.
The string will be internally parsed and split at spaces.
The following expressions are valid, with `value` being either a C-String or
a `std::basic_string` with `char` or `wchar_t`.
\code{.cpp}
cmd="value";
cmd(value);
\endcode
The property can only be used for assignments.
*/
constexpr static ::boost::process::detail::cmd_ cmd;


}}


#endif
4 changes: 2 additions & 2 deletions include/boost/process/detail/async_handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ struct needs_io_service<T>
};

template<typename ...Args>
boost::asio::io_service &get_io_service_var(boost::asio::io_service & f, Args&...args)
boost::asio::io_service &get_io_service_var(boost::asio::io_service & f, Args&...)
{
return f;
}

template<typename First, typename ...Args>
boost::asio::io_service &get_io_service_var(First & f, Args&...args)
boost::asio::io_service &get_io_service_var(First&, Args&...args)
{
return get_io_service_var(args...);
}
Expand Down

0 comments on commit 477a60e

Please sign in to comment.