mirror of
https://github.com/swaywm/sway.git
synced 2024-11-26 18:01:29 +00:00
Fix dangling file descriptors (fixes #1152)
This commit is contained in:
parent
270e01ce6d
commit
50a31a6c88
|
@ -161,7 +161,8 @@ int ipc_handle_connection(int fd, uint32_t mask, void *data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int flags;
|
int flags;
|
||||||
if ((flags=fcntl(client_fd, F_GETFD)) == -1 || fcntl(client_fd, F_SETFD, flags|FD_CLOEXEC) == -1) {
|
if ((flags = fcntl(client_fd, F_GETFD)) == -1
|
||||||
|
|| fcntl(client_fd, F_SETFD, flags|FD_CLOEXEC) == -1) {
|
||||||
sway_log_errno(L_ERROR, "Unable to set CLOEXEC on IPC client socket");
|
sway_log_errno(L_ERROR, "Unable to set CLOEXEC on IPC client socket");
|
||||||
close(client_fd);
|
close(client_fd);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -199,6 +200,8 @@ int ipc_client_handle_readable(int client_fd, uint32_t mask, void *data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mask & WLC_EVENT_HANGUP) {
|
if (mask & WLC_EVENT_HANGUP) {
|
||||||
|
sway_log(L_DEBUG, "Client %d hung up", client->fd);
|
||||||
|
close(client->fd);
|
||||||
client->fd = -1;
|
client->fd = -1;
|
||||||
ipc_client_disconnect(client);
|
ipc_client_disconnect(client);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue