Figure out absolute path for the pid file before daemonizing

This allows relative path to be used in the same way as was already
supported by wpa_supplicant.
This commit is contained in:
Jouni Malinen 2009-08-15 20:09:24 +03:00
parent ba30964b60
commit cedf947308

View file

@ -393,7 +393,7 @@ int main(int argc, char *argv[])
int ret = 1; int ret = 1;
size_t i; size_t i;
int c, debug = 0, daemonize = 0; int c, debug = 0, daemonize = 0;
const char *pid_file = NULL; char *pid_file = NULL;
for (;;) { for (;;) {
c = getopt(argc, argv, "BdhKP:tv"); c = getopt(argc, argv, "BdhKP:tv");
@ -415,7 +415,8 @@ int main(int argc, char *argv[])
wpa_debug_show_keys++; wpa_debug_show_keys++;
break; break;
case 'P': case 'P':
pid_file = optarg; os_free(pid_file);
pid_file = os_rel2abs_path(optarg);
break; break;
case 't': case 't':
wpa_debug_timestamp++; wpa_debug_timestamp++;
@ -459,6 +460,7 @@ int main(int argc, char *argv[])
ret = 0; ret = 0;
out: out:
os_free(pid_file);
/* Deinitialize all interfaces */ /* Deinitialize all interfaces */
for (i = 0; i < interfaces.count; i++) for (i = 0; i < interfaces.count; i++)
hostapd_interface_deinit(interfaces.iface[i]); hostapd_interface_deinit(interfaces.iface[i]);