From 8a913d8bf36ed17a9c88e4b8bc6bd94d35a3a414 Mon Sep 17 00:00:00 2001 From: Jafar Abdi Date: Tue, 15 Dec 2020 22:39:01 +0300 Subject: [PATCH] getTaskId(): Replace '-' in hostname with '_' (#223) --- core/src/introspection.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/src/introspection.cpp b/core/src/introspection.cpp index e2225bd2..588b9e99 100644 --- a/core/src/introspection.cpp +++ b/core/src/introspection.cpp @@ -57,6 +57,8 @@ 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), '-', '_'); oss << our_hostname << "_" << getpid() << "_" << reinterpret_cast(task); return oss.str(); }