aboutsummaryrefslogtreecommitdiff
path: root/src/base/platform/unix
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2024-06-24 00:06:25 +0800
committercrupest <crupest@outlook.com>2024-10-06 18:03:42 +0800
commitb2a331aa527bdd5f4d91727904cc5c66fe897d62 (patch)
treee84d0bfdd4ed63255024e02954963d8c564ad024 /src/base/platform/unix
parentdfe62dcf8bcefc523b466e127c3edc4dc2756629 (diff)
downloadcru-b2a331aa527bdd5f4d91727904cc5c66fe897d62.tar.gz
cru-b2a331aa527bdd5f4d91727904cc5c66fe897d62.tar.bz2
cru-b2a331aa527bdd5f4d91727904cc5c66fe897d62.zip
Done Stream refactor.
NEED TEST: BufferStream, AutoReadStream, SubProcess.
Diffstat (limited to 'src/base/platform/unix')
-rw-r--r--src/base/platform/unix/PosixSpawnSubProcess.cpp4
-rw-r--r--src/base/platform/unix/UnixFileStream.cpp10
2 files changed, 3 insertions, 11 deletions
diff --git a/src/base/platform/unix/PosixSpawnSubProcess.cpp b/src/base/platform/unix/PosixSpawnSubProcess.cpp
index 75d48cc2..5e09c494 100644
--- a/src/base/platform/unix/PosixSpawnSubProcess.cpp
+++ b/src/base/platform/unix/PosixSpawnSubProcess.cpp
@@ -28,9 +28,9 @@ PosixSpawnSubProcessImpl::PosixSpawnSubProcessImpl()
stderr_pipe_.GetSelfFileDescriptor(), false, true, false, true);
stdout_buffer_stream_ =
- std::make_unique<io::AutoReadStream>(stdout_stream_.get(), false);
+ std::make_unique<io::AutoReadStream>(stdout_stream_.get(), true, false);
stderr_buffer_stream_ =
- std::make_unique<io::AutoReadStream>(stderr_stream_.get(), false);
+ std::make_unique<io::AutoReadStream>(stderr_stream_.get(), true, false);
}
PosixSpawnSubProcessImpl::~PosixSpawnSubProcessImpl() {}
diff --git a/src/base/platform/unix/UnixFileStream.cpp b/src/base/platform/unix/UnixFileStream.cpp
index c53bbbaa..6d8bab25 100644
--- a/src/base/platform/unix/UnixFileStream.cpp
+++ b/src/base/platform/unix/UnixFileStream.cpp
@@ -61,15 +61,7 @@ UnixFileStream::UnixFileStream(int fd, bool can_seek, bool can_read,
auto_close_ = auto_close;
}
-UnixFileStream::~UnixFileStream() {
- if (auto_close_ && file_descriptor_ >= 0) {
- if (::close(file_descriptor_) == -1) {
- // We are in destructor, so we can not throw.
- CRU_LOG_WARN(u"Failed to close file descriptor {}, errno {}.",
- file_descriptor_, errno);
- }
- }
-}
+UnixFileStream::~UnixFileStream() { DoClose(); }
Index UnixFileStream::DoSeek(Index offset, SeekOrigin origin) {
off_t result = ::lseek(file_descriptor_, offset, MapSeekOrigin(origin));