Skip to content

Commit

Permalink
Merge pull request #1898 from zmostafa/iox-1692-wrap-c-calls-in-posix…
Browse files Browse the repository at this point in the history
…call-introspection

Introspection-app Wrap c calls in posixCall
  • Loading branch information
mossmaurice authored Feb 28, 2023
2 parents ff49811 + 0facdea commit b958089
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
1 change: 1 addition & 0 deletions doc/website/release-notes/iceoryx-unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
- Remove `algorithm::uniqueMergeSortedContainers` from `algorithm.hpp`
- Move `std::string` conversion function to `iceoryx_dust` [\#1612](https://github.com/eclipse-iceoryx/iceoryx/issues/1612)
- The posix call `unlink` is directly used in `UnixDomainSocket` [\#1622](https://github.com/eclipse-iceoryx/iceoryx/issues/1622)
- Wrap all C calls in posixCall in IntrospectionApp [\#1692](https://github.com/eclipse-iceoryx/iceoryx/issues/1692)

**Workflow:**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ static const std::map<PrettyOptions, uint32_t> prettyMap = {


/// @brief base class for introspection
/// @todo iox-#1692 Wrap all C calls with posixCall
class IntrospectionApp
{
public:
Expand Down
24 changes: 13 additions & 11 deletions tools/introspection/source/introspection_app.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2019 - 2020 by Robert Bosch GmbH. All rights reserved.
// Copyright (c) 2020 - 2021 by Apex.AI Inc. All rights reserved.
// Copyright (c) 2020 - 2023 by Apex.AI Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -228,15 +228,16 @@ void IntrospectionApp::waitForUserInput(int32_t timeoutMs)
fileDesc.fd = STDIN_FILENO;
fileDesc.events = POLLIN;
constexpr size_t nFileDesc = 1u;
/// @todo iox-#1692 Wrap kernel calls with posixCall
int32_t eventCount = poll(&fileDesc, nFileDesc, timeoutMs);

// Event detected
if ((eventCount == nFileDesc) && (fileDesc.revents == POLLIN))
{
updateDisplayYX();
refreshTerminal();
}
iox::posix::posixCall(poll)(&fileDesc, nFileDesc, timeoutMs)
.failureReturnValue(-1)
.evaluate()
.and_then([&](auto eventCount) {
if (static_cast<size_t>(eventCount.value) == nFileDesc && fileDesc.revents == POLLIN)
{
this->updateDisplayYX();
this->refreshTerminal();
}
});
}

void IntrospectionApp::prettyPrint(const std::string& str, const PrettyOptions pr)
Expand Down Expand Up @@ -791,7 +792,8 @@ void IntrospectionApp::runIntrospection(const iox::units::Duration updatePeriod,
}
}

getchar();
iox::posix::posixCall(getchar)().failureReturnValue(EOF).evaluate().expect(
"unable to exit the introspection client since getchar failed");
closeTerminal();
}

Expand Down

0 comments on commit b958089

Please sign in to comment.