diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2021-01-31 21:11:22 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2021-01-31 22:48:45 +0100 |
commit | 8be5df459a676555573e81b168589c54c4f5ba45 (patch) | |
tree | a4629b663d8b8ee035bb176c34a122d4ed62fc58 /src | |
parent | 4ca702e1ec9a820c89ba68b97b42509dfce8059d (diff) | |
download | rebel-8be5df459a676555573e81b168589c54c4f5ba45.tar rebel-8be5df459a676555573e81b168589c54c4f5ba45.zip |
prepared_command: close pipe read FD in parent, assert close success
Diffstat (limited to 'src')
-rw-r--r-- | src/prepared_command.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/prepared_command.rs b/src/prepared_command.rs index 00d648e..39b22ea 100644 --- a/src/prepared_command.rs +++ b/src/prepared_command.rs @@ -25,7 +25,7 @@ pub struct PreparedCommand { impl Drop for PreparedCommand { fn drop(&mut self) { - let _ = unistd::close(self.pipew); + assert!(unistd::close(self.pipew).is_ok()); } } @@ -54,7 +54,9 @@ impl PreparedCommandBuilder { unsafe { match unistd::fork().to_io_result()? { unistd::ForkResult::Parent { child } => { - return Ok(PreparedCommand { child, pipew }); + let cmd = PreparedCommand { child, pipew }; + assert!(unistd::close(piper).is_ok()); + return Ok(cmd); } unistd::ForkResult::Child => {} } |