linux-stream-relay 的 C++17 重写:Linux 用户态字节流中继。
unique_fd.hpp:UniqueFd(禁拷贝,可 move)endpoint.hpp/.cpp:open_endpoint→optional<UniqueFd>relay_io.hpp/.cpp:write_fullyring_buffer.hpp:RingBuffer(mutex + condition_variable;push 短超时可看见停)stop_flag.hpp/.cpp:SIGINT→ 旗;读侧close优雅停,写侧排空relay_workers.hpp/.cpp:reader_task/writer_task(短超时poll+enum class WaitResult)main.cpp:解析、打开;unique_ptr握RingBuffer;起线程、joinCMakeLists.txt:C++17 目标relay(-Wall -Wextra、pthread)
cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug
cmake --build build
产物:build/relay。也可用原来的手写 c++ ...(见 git 历史);日常以 CMake 为准。
(compile_flags.txt 仍给编辑器做补全用。)
echo 'hello' | ./build/relay
./build/relay some.bin
./build/relay some.bin out.bin
echo 'hello' | ./build/relay - out.bin