/*! * \brief Set title of process using format string * * \param exceeded_out Number of bytes longer than the max process title size * \param fmt Format string * * \return Whether the process title was successfully set */ bool set_process_title_v(size_t *exceeded_out, const char *fmt, ...) { char buf[1024]; va_list ap; va_start(ap, fmt); int ret = vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); if (ret < 0) { return false; } size_t n = (size_t) ret >= sizeof(buf) ? sizeof(buf) - 1 : ret; size_t n_set; if (!set_process_title(buf, n, &n_set)) { return false; } if (exceeded_out) { *exceeded_out = n - n_set; } return true; }
void CUtils::set_process_title(const char* format, ...) { va_list args; va_start(args, format); utils::VaListHelper vlh(args); char title[PATH_MAX]; vsnprintf(title, sizeof(title), format, args); set_process_title(std::string(title)); }