diff options
author | crupest <crupest@outlook.com> | 2024-06-24 00:06:25 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2024-06-25 00:12:29 +0800 |
commit | 807c1dfe8a897f9c61bf3549ff2566917b53023b (patch) | |
tree | 8f0bfed314747ff570fa99577e8954060194ed7f /src/common/platform/unix/PosixSpawnSubProcess.cpp | |
parent | 2f5651cd1a1efb136179cdbcb3b29ed0cc11ca2a (diff) | |
download | cru-807c1dfe8a897f9c61bf3549ff2566917b53023b.tar.gz cru-807c1dfe8a897f9c61bf3549ff2566917b53023b.tar.bz2 cru-807c1dfe8a897f9c61bf3549ff2566917b53023b.zip |
feat: fix linux build, complete PosixSpawnSubProcess.
NEED TEST: BufferStream, AutoReadStream, SubProcess.
Diffstat (limited to 'src/common/platform/unix/PosixSpawnSubProcess.cpp')
-rw-r--r-- | src/common/platform/unix/PosixSpawnSubProcess.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/common/platform/unix/PosixSpawnSubProcess.cpp b/src/common/platform/unix/PosixSpawnSubProcess.cpp index fba536e5..1d69f54a 100644 --- a/src/common/platform/unix/PosixSpawnSubProcess.cpp +++ b/src/common/platform/unix/PosixSpawnSubProcess.cpp @@ -107,6 +107,15 @@ void PosixSpawnSubProcess::PlatformCreateProcess() { error = posix_spawn_file_actions_adddup2( &file_actions, stderr_pipe_.GetOtherFileDescriptor(), STDERR_FILENO); check_error(u"Failed to call posix_spawn_file_actions_adddup2 on stderr."); + error = posix_spawn_file_actions_addclose( + &file_actions, stdin_pipe_.GetSelfFileDescriptor()); + check_error(u"Failed to call posix_spawn_file_actions_addclose on stdin."); + error = posix_spawn_file_actions_addclose( + &file_actions, stdout_pipe_.GetSelfFileDescriptor()); + check_error(u"Failed to call posix_spawn_file_actions_addclose on stdout."); + error = posix_spawn_file_actions_addclose( + &file_actions, stderr_pipe_.GetSelfFileDescriptor()); + check_error(u"Failed to call posix_spawn_file_actions_addclose on stderr."); posix_spawnattr_t attr; error = posix_spawnattr_init(&attr); @@ -131,6 +140,13 @@ void PosixSpawnSubProcess::PlatformCreateProcess() { error = posix_spawnp(&pid_, exe.c_str(), &file_actions, &attr, argv, envp); check_error(u"Failed to call posix_spawnp."); + + error = ::close(stdin_pipe_.GetOtherFileDescriptor()); + check_error(u"Failed to close stdin."); + error = ::close(stdout_pipe_.GetOtherFileDescriptor()); + check_error(u"Failed to close stdout."); + error = ::close(stderr_pipe_.GetOtherFileDescriptor()); + check_error(u"Failed to close stderr."); } SubProcessExitResult PosixSpawnSubProcess::PlatformWaitForProcess() { |