mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 12:08:14 +00:00
LibCore: Implement LocalSocket::release_fd
release_fd() releases the fd associated with the LocalSocket it is called on. This is analogous to release_value() on container objects in AK, after which the object does not contain the value.
This commit is contained in:
parent
89d9a1afc0
commit
259ed04087
2 changed files with 17 additions and 0 deletions
|
@ -535,4 +535,15 @@ ErrorOr<size_t> LocalSocket::read_without_waiting(Bytes buffer)
|
|||
return m_helper.read(buffer, MSG_DONTWAIT);
|
||||
}
|
||||
|
||||
ErrorOr<int> LocalSocket::release_fd()
|
||||
{
|
||||
if (!is_open()) {
|
||||
return Error::from_errno(ENOTCONN);
|
||||
}
|
||||
|
||||
auto fd = m_helper.fd();
|
||||
m_helper.set_fd(-1);
|
||||
return fd;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue