diff --git a/src/uvw/util.hpp b/src/uvw/util.hpp index 8c576655..fdb7f1de 100644 --- a/src/uvw/util.hpp +++ b/src/uvw/util.hpp @@ -584,6 +584,31 @@ struct Utilities { return avg; } + /** + * @brief Gets the title of the current process. + * @return The process title. + */ + static std::string processTitle() { + std::size_t size = details::DEFAULT_SIZE; + char buf[details::DEFAULT_SIZE]; + std::string str{}; + + if(0 == uv_get_process_title(buf, size)) { + str.assign(buf, size); + } + + return str; + } + + /** + * @brief Sets the current process title. + * @param title The process title to be set. + * @return True in case of success, false otherwise. + */ + static bool processTitle(std::string title) { + return (0 == uv_set_process_title(title.c_str())); + } + /** * @brief Gets memory information (in bytes). * @return Memory information. diff --git a/test/uvw/util.cpp b/test/uvw/util.cpp index 2ff6025a..dd407477 100644 --- a/test/uvw/util.cpp +++ b/test/uvw/util.cpp @@ -99,4 +99,7 @@ TEST(Util, Utilities) { ASSERT_FALSE(uvw::Utilities::exepath().empty()); ASSERT_FALSE(uvw::Utilities::cwd().empty()); ASSERT_TRUE(uvw::Utilities::chdir(uvw::Utilities::cwd())); + + ASSERT_NE(uvw::Utilities::processTitle(), std::string{}); + ASSERT_TRUE(uvw::Utilities::processTitle(uvw::Utilities::processTitle())); }