Skip to content

Commit 8a913d8

Browse files
authored
getTaskId(): Replace '-' in hostname with '_' (#223)
1 parent 9f18219 commit 8a913d8

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

core/src/introspection.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ std::string getTaskId(const TaskPrivate* task) {
5757
std::ostringstream oss;
5858
char our_hostname[256] = { 0 };
5959
gethostname(our_hostname, sizeof(our_hostname) - 1);
60+
// Hostname could have `-` as a character but this is an invalid character in ROS so we replace it with `_`
61+
std::replace(std::begin(our_hostname), std::end(our_hostname), '-', '_');
6062
oss << our_hostname << "_" << getpid() << "_" << reinterpret_cast<std::size_t>(task);
6163
return oss.str();
6264
}

0 commit comments

Comments
 (0)