mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:37:43 +00:00
SystemServer: Unlink before binding a new socket
Prevent "Address already in use" issues when restarting a service.
This commit is contained in:
parent
b14fedd02a
commit
a13ffffbec
1 changed files with 4 additions and 0 deletions
|
@ -35,6 +35,10 @@ ErrorOr<void> Service::setup_socket(SocketDescriptor& socket)
|
|||
{
|
||||
VERIFY(socket.fd == -1);
|
||||
|
||||
// Note: The purpose of this syscall is to remove potential left-over of previous portal.
|
||||
// The return value is discarded as sockets are not always there, and unlinking a non-existent path is considered as a failure.
|
||||
(void)Core::System::unlink(socket.path);
|
||||
|
||||
TRY(Core::Directory::create(LexicalPath(socket.path).parent(), Core::Directory::CreateDirectories::Yes));
|
||||
|
||||
// Note: we use SOCK_CLOEXEC here to make sure we don't leak every socket to
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue