Commits

Bryan O'Sullivan  committed 85b1629

Don't open netlink socket until after we become a daemon.
daemon() helpfully closes the netlink fd, but doesn't document this
behaviour. Suck.

  • Participants
  • Parent commits a836f69

Comments (0)

Files changed (2)

 	return pid;
     }
     
-    do_log(LOG_DEBUG, "%s %s %s", NP_SCRIPT, ifname, action);
+    do_log(LOG_INFO, "%s %s %s", NP_SCRIPT, ifname, action);
     
     execl(NP_SCRIPT, NP_SCRIPT, ifname, action, NULL);
 
 	case LOG_ERR:
 	    fputs("Error: ", fp);
 	    break;
+	case LOG_INFO:
 	case LOG_DEBUG:
 	    break;
 	default:
 	probe_interfaces();
     }
     
-    int fd = netlink_open();
-
-    netlink_request_dump(fd);
-    netlink_receive_dump(fd, if_info_save_interface, NULL);
-
     if (!foreground) {
 	if (daemon(0, 0) == -1) {
 	    do_log(LOG_ERR, "daemon: %m");
 	openlog("netplugd", LOG_PID, LOG_DAEMON);
     }
     
+    int fd = netlink_open();
+
+    netlink_request_dump(fd);
+    netlink_receive_dump(fd, if_info_save_interface, NULL);
+
     netlink_listen(fd, handle_interface, NULL);
 
     return fd ? 0 : 0;