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)));
}
}
};
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':
return -1;
}
- interface_name = argv[optind++];
+ interface_name = avahi_strdup(argv[optind++]);
}
if (optind != argc) {
int main(int argc, char*argv[]) {
int r = 1;
int wrote_pid_file = 0;
+ char *log_ident = NULL;
avahi_init_proc_title(argc, 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) {
} 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;
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;
}
case AVAHI_SERVER_RUNNING:
avahi_log_info("Server startup complete. Host name is %s. Local service cookie is %u.", avahi_server_get_host_name_fqdn(s), avahi_server_get_local_service_cookie(s));
- avahi_set_proc_title("%s: running [%s]", argv0, avahi_server_get_host_name_fqdn(s));
+ avahi_set_proc_title(argv0, "%s: running [%s]", argv0, avahi_server_get_host_name_fqdn(s));
static_service_add_to_server();
static_hosts_add_to_server();
case AVAHI_SERVER_COLLISION: {
char *n;
- avahi_set_proc_title("%s: collision", argv0);
+ avahi_set_proc_title(argv0, "%s: collision", argv0);
static_service_remove_from_server();
static_hosts_remove_from_server();
case AVAHI_SERVER_REGISTERING:
- avahi_set_proc_title("%s: registering [%s]", argv0, avahi_server_get_host_name_fqdn(s));
+ avahi_set_proc_title(argv0, "%s: registering [%s]", argv0, avahi_server_get_host_name_fqdn(s));
static_service_remove_from_server();
static_hosts_remove_from_server();
#endif
avahi_log_info("%s "PACKAGE_VERSION" starting up.", argv0);
- avahi_set_proc_title("%s: starting up", argv0);
+ avahi_set_proc_title(argv0, "%s: starting up", argv0);
if (run_server(&config) == 0)
r = 0;