/* argv[0] without directory names. */
const char *program_name;
-/* Ordinarily "" but set to "monitor" for a monitor process or "worker" for a
- * worker process. */
-const char *subprogram_name = "";
+/* Name for the currently running thread or process, for log messages, process
+ * listings, and debuggers. */
+DEFINE_PER_THREAD_MALLOCED_DATA(char *, subprogram_name);
/* --version option output. */
static char *program_version;
void
ovs_error_valist(int err_no, const char *format, va_list args)
{
+ const char *subprogram_name = get_subprogram_name();
int save_errno = errno;
if (subprogram_name[0]) {
}
}
+/* Returns the name of the currently running thread or process. */
+const char *
+get_subprogram_name(void)
+{
+ const char *name = subprogram_name_get();
+ return name ? name : "";
+}
+
+/* Sets 'name' as the name of the currently running thread or process. (This
+ * appears in log messages.) */
+void
+set_subprogram_name(const char *name)
+{
+ free(subprogram_name_set(xstrdup(name)));
+}
+
/* Returns a pointer to a string describing the program version. The
* caller must not modify or free the returned string.
*/
int error = errno;
free(buf);
if (error != ERANGE) {
- VLOG_WARN("getcwd failed (%s)", strerror(error));
+ VLOG_WARN("getcwd failed (%s)", ovs_strerror(error));
return NULL;
}
size *= 2;
linkname = xreadlink(fn);
if (!linkname) {
- VLOG_WARN("%s: readlink failed (%s)", filename, strerror(errno));
+ VLOG_WARN("%s: readlink failed (%s)",
+ filename, ovs_strerror(errno));
return fn;
}