builtin: Close other end of socketpair after fork

We will not get a socket hangup if we have duplicates socket fds in the
parent or child, so make sure we clean this up properly after fork.
This commit is contained in:
Kenny Levinsen 2022-03-03 14:41:52 +01:00
parent abcecbb53b
commit 46c83972fe

View file

@ -634,6 +634,7 @@ static struct libseat *builtin_open_seat(const struct libseat_seat_listener *lis
close(fds[1]);
return NULL;
} else if (pid == 0) {
close(fds[1]);
int fd = fds[0];
int res = 0;
struct server server = {0};
@ -662,6 +663,7 @@ static struct libseat *builtin_open_seat(const struct libseat_seat_listener *lis
close(fd);
exit(res);
} else {
close(fds[0]);
int fd = fds[1];
return _open_seat(listener, data, fd);
}