Skip to content

Commit

Permalink
iox-eclipse-iceoryx#751 expect uses 'write' instead of 'std::cout' so…
Browse files Browse the repository at this point in the history
… that it can be used from within a signal handler

Signed-off-by: Christian Eltzschig <me@elchris.org>
  • Loading branch information
elfenpiff committed Jun 23, 2022
1 parent 10f2ab0 commit 9a4fb4c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@

#include "iceoryx_hoofs/cxx/function_ref.hpp"
#include "iceoryx_hoofs/cxx/type_traits.hpp"
#include "iceoryx_hoofs/platform/unistd.hpp"

#include <iostream>
#include <cstring>
#include <utility>

namespace iox
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ inline void Expect<Derived>::expect(const StringType& msg) const noexcept

if (!(*static_cast<const Derived*>(this)))
{
std::cout << msg << std::endl;
// it is possible that expect is called inside an error handler therefore we
// use write
IOX_DISCARD_RESULT(write(STDERR_FILENO, &msg[0], strlen(&msg[0])));
Ensures(false);
}
}
Expand All @@ -53,7 +55,9 @@ inline ValueType& ExpectWithValue<Derived, ValueType>::expect(const StringType&

if (!(*derivedThis))
{
std::cout << msg << std::endl;
// it is possible that expect is called inside an error handler therefore we
// use write
IOX_DISCARD_RESULT(write(STDERR_FILENO, &msg[0], strlen(&msg[0])));
Ensures(false);
}

Expand Down

0 comments on commit 9a4fb4c

Please sign in to comment.