Skip to content
Snippets Groups Projects
Commit 548048f4 authored by Nick Zavaritsky's avatar Nick Zavaritsky
Browse files

Change proctitle as suggested during discussions

tarantool script.lua <status>: custom proc title
parent 585ffa32
No related branches found
No related tags found
No related merge requests found
......@@ -79,7 +79,7 @@ void title_update()
const char *script_name_short = my_basename(script_name);
const char *interpretor_name_short = my_basename(interpretor_name);
const char *part1 = "tarantool", *part2 = status, *part3 = NULL;
const char *part1 = "tarantool", *part2 = NULL, *part3 = status;
/*
* prefix
......@@ -99,23 +99,27 @@ void title_update()
* scriptname, ex: tarantool/tarantoolctl
*/
if (memcmp(script_name_short, interpretor_name_short,
strlen(interpretor_name_short)) != 0)
part3 = interpretor_name_short;
strlen(interpretor_name_short)) == 0) {
part1 = script_name_short;
} else {
part1 = interpretor_name_short;
part2 = script_name_short;
}
}
#define OUTPUT(...) snprintf(output, output_end - output, __VA_ARGS__)
assert(part1);
if (part2) {
if (part3) {
rc = OUTPUT("%s/%s (%s)", part1, part2, part3);
rc = OUTPUT("%s %s <%s>:", part1, part2, part3);
} else {
rc = OUTPUT("%s/%s", part1, part2);
rc = OUTPUT("%s %s:", part1, part2);
}
} else {
if (part3) {
rc = OUTPUT("%s (%s)", part1, part3);
rc = OUTPUT("%s <%s>:", part1, part3);
} else {
rc = OUTPUT("%s", part1);
rc = OUTPUT("%s:", part1);
}
}
if (rc < 0 || (output += rc) >= output_end)
......@@ -125,7 +129,7 @@ void title_update()
* custom title
*/
if (custom) {
rc = OUTPUT(": %s", custom);
rc = OUTPUT(" %s", custom);
if (rc < 0 || (output += rc) >= output_end)
goto done;
}
......
#ifndef TARANTOOL_PROCESS_TITLE_H_INCLUDED
#define TARANTOOL_PROCESS_TITLE_H_INCLUDED
#ifndef TARANTOOL_TITLE_H_INCLUDED
#define TARANTOOL_TITLE_H_INCLUDED
/*
* Copyright 2010-2015, Tarantool AUTHORS, please see AUTHORS file.
*
......@@ -33,30 +33,30 @@
/**
*
* script.lua/running (tarantool): my lovely pony
* tarantool script.lua <running>: my lovely pony
*
* ^^^^^^^ ^^^^^^^^^^^^^^
* ^^^^^^^^^^ status ^^^^^^^^^ custom title
* script name interpretor name
* ^^^^^^^^^^ ^^^^^^^^^ ^^^^^^^^^^^^^^
* ^^^^^^^^^ script name status custom title
* interpretor name
*
*
* Parts missing:
*
* 1) no custom title
* 1) no custom title (note the trailing colon - its intentional)
*
* script.lua/running (tarantool)
* tarantool script.lua <running>:
*
* 2) script name missing
*
* tarantool/running: my lovely pony
* tarantool <running>: my lovely pony
*
* 3) scriptname.matches(tarantool.*)
*
* tarantoolctl/running: my lovely pony
* tarantoolctl <running>: my lovely pony
*
* 4) no status
*
* script.lua (tarantool): my lovely pony
* tarantool script.lua: my lovely pony
*/
#include <stddef.h>
......@@ -100,4 +100,4 @@ const char *title_get_status();
} /* extern "C" */
#endif
#endif /* TARANTOOL_PROCESS_TITLE_H_INCLUDED */
#endif /* TARANTOOL_TITLE_H_INCLUDED */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment