Skip to content

Commit

Permalink
Replace '.' with '_' in task id (#3)
Browse files Browse the repository at this point in the history
* Replace '.' with '_' in task id

* Fix whitespace

* Fix initializer list spacing

* Fix reference spacing

---------

Co-authored-by: Calen Robinson <c.robinson@sarcos.com>
  • Loading branch information
2 people authored and Michael Wiznitzer committed Jul 3, 2023
1 parent 82ba38c commit 3a644b9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions core/src/introspection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,13 @@ std::string getTaskId(const TaskPrivate* task) {
std::ostringstream oss;
char our_hostname[256] = { 0 };
gethostname(our_hostname, sizeof(our_hostname) - 1);
// Hostname could have `-` as a character but this is an invalid character in ROS so we replace it with `_`
std::replace(std::begin(our_hostname), std::end(our_hostname), '-', '_');

// Hostname could have characters that are invalid in ROS so we replace them with `_`
std::vector<char> invalid_characters = { '-', '.' };
for (auto& character : invalid_characters) {
std::replace(std::begin(our_hostname), std::end(our_hostname), character, '_');
}

oss << our_hostname << "_" << getpid() << "_" << reinterpret_cast<std::size_t>(task);
return oss.str();
}
Expand Down

0 comments on commit 3a644b9

Please sign in to comment.