summaryrefslogtreecommitdiff
path: root/avahi-autoipd
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2006-08-31 18:32:27 +0000
committerLennart Poettering <lennart@poettering.net>2006-08-31 18:32:27 +0000
commit9d709a294b81066a0942a7a642df1b3d4940ad26 (patch)
tree0bb37c5bd2622dba6b3fdeeeb92b1edaac6b1963 /avahi-autoipd
parent2a3d0eaa15047ec792cddc1e7e821f525d718648 (diff)
downloadavahi-9d709a294b81066a0942a7a642df1b3d4940ad26.tar.gz
avahi_set_proc_title(): change the process name with prctl() if available
git-svn-id: file:///home/lennart/svn/public/avahi/trunk@1300 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
Diffstat (limited to 'avahi-autoipd')
-rw-r--r--avahi-autoipd/main.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/avahi-autoipd/main.c b/avahi-autoipd/main.c
index 1b3c9ed..6d83d3a 100644
--- a/avahi-autoipd/main.c
+++ b/avahi-autoipd/main.c
@@ -267,13 +267,13 @@ static void set_state(State st, int reset_counter, uint32_t address) {
if (modify_proc_title) {
if (state == STATE_SLEEPING)
- avahi_set_proc_title("%s: sleeping", argv0);
+ avahi_set_proc_title(argv0, "%s(%s): sleeping", argv0, interface_name);
else if (state == STATE_ANNOUNCING)
- avahi_set_proc_title("%s: announcing %s", argv0, inet_ntop(AF_INET, &address, buf, sizeof(buf)));
+ avahi_set_proc_title(argv0, "%s(%s): announcing %s", argv0, interface_name, inet_ntop(AF_INET, &address, buf, sizeof(buf)));
else if (state == STATE_RUNNING)
- avahi_set_proc_title("%s: bound %s", argv0, inet_ntop(AF_INET, &address, buf, sizeof(buf)));
+ avahi_set_proc_title(argv0, "%s(%s): bound %s", argv0, interface_name, inet_ntop(AF_INET, &address, buf, sizeof(buf)));
else
- avahi_set_proc_title("%s: probing %s", argv0, inet_ntop(AF_INET, &address, buf, sizeof(buf)));
+ avahi_set_proc_title(argv0, "%s(%s): probing %s", argv0, interface_name, inet_ntop(AF_INET, &address, buf, sizeof(buf)));
}
}
@@ -840,7 +840,7 @@ static int parse_command_line(int argc, char *argv[]) {
};
opterr = 0;
- while ((c = getopt_long(argc, argv, "hDkVrcS:", long_options, NULL)) >= 0) {
+ while ((c = getopt_long(argc, argv, "hDskrcVS:w", long_options, NULL)) >= 0) {
switch(c) {
case 's':
@@ -903,7 +903,7 @@ static int parse_command_line(int argc, char *argv[]) {
return -1;
}
- interface_name = argv[optind++];
+ interface_name = avahi_strdup(argv[optind++]);
}
if (optind != argc) {
@@ -921,6 +921,7 @@ static const char* pid_file_proc(void) {
int main(int argc, char*argv[]) {
int r = 1;
int wrote_pid_file = 0;
+ char *log_ident = NULL;
avahi_init_proc_title(argc, argv);
@@ -929,12 +930,15 @@ int main(int argc, char*argv[]) {
else
argv0 = argv[0];
- daemon_pid_file_ident = daemon_log_ident = argv0;
- daemon_pid_file_proc = pid_file_proc;
+ argv0 = avahi_strdup(argv0);
+
+ daemon_log_ident = argv0;
if (parse_command_line(argc, argv) < 0)
goto finish;
+ daemon_log_ident = log_ident = avahi_strdup_printf("%s(%s)", argv0, interface_name);
+ daemon_pid_file_proc = pid_file_proc;
pid_file_name = avahi_strdup_printf(AVAHI_RUNTIME_DIR"/avahi-autoipd.%s.pid", interface_name);
if (command == DAEMON_RUN) {
@@ -993,6 +997,8 @@ int main(int argc, char*argv[]) {
} else
wrote_pid_file = 1;
+ avahi_set_proc_title(argv0, "%s(%s): starting up", argv0, interface_name);
+
if (loop(ifindex, start_address) < 0)
goto finish;
@@ -1031,6 +1037,11 @@ finish:
if (wrote_pid_file)
daemon_pid_file_remove();
+ avahi_free(log_ident);
+ avahi_free(pid_file_name);
+ avahi_free(argv0);
+ avahi_free(interface_name);
+
return r;
}