check open syscall error in PipeStream::do_connect (#1150)

This commit is contained in:
Hailey Somerville 2023-10-26 07:35:25 +11:00 committed by GitHub
parent 44643fdb8b
commit 5fc40f1049
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -58,6 +58,9 @@ PipeStream::PipeStream(PcmStream::Listener* pcmListener, boost::asio::io_context
void PipeStream::do_connect()
{
int fd = open(uri_.path.c_str(), O_RDONLY | O_NONBLOCK);
if (fd < 0)
throw SnapException("failed to open fifo \"" + uri_.path + "\": " + cpt::to_string(errno));
int pipe_size = -1;
#if !defined(MACOS) && !defined(FREEBSD)
pipe_size = fcntl(fd, F_GETPIPE_SZ);