NetworkServer: Kill running DHCPServer before starting our own

We cannot run two DHCPServers at once, let's just kill the one that was
started previously.
This commit is contained in:
Maciej 2022-07-01 18:01:02 +02:00 committed by Sam Atkins
parent 8526c3f680
commit df7b7cbfa4
Notes: sideshowbarker 2024-07-17 09:34:40 +09:00

View File

@ -22,6 +22,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
TRY(Core::System::unveil("/bin/DHCPClient", "x"));
TRY(Core::System::unveil("/etc/Network.ini", "r"));
TRY(Core::System::unveil("/bin/ifconfig", "x"));
TRY(Core::System::unveil("/bin/killall", "x"));
TRY(Core::System::unveil("/bin/route", "x"));
TRY(Core::System::unveil(nullptr, nullptr));
@ -88,6 +89,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
for (auto& iface : interfaces_with_dhcp_enabled)
args.append(const_cast<char*>(iface.characters()));
args.append(nullptr);
MUST(Core::command("killall", { "DHCPClient" }, {}));
auto dhcp_client_pid = TRY(Core::System::posix_spawnp("DHCPClient", nullptr, nullptr, args.data(), environ));
TRY(Core::System::disown(dhcp_client_pid));
}