|
1 | 1 | //! Safe wrappers around posix_spawn* functions found in the libc "spawn.h" header.
|
2 | 2 |
|
3 |
| -use std::{ffi::CStr, mem, os::fd::RawFd}; |
4 |
| - |
5 | 3 | #[cfg(any(feature = "fs", feature = "term"))]
|
6 | 4 | use crate::fcntl::OFlag;
|
7 | 5 | #[cfg(feature = "signal")]
|
8 | 6 | use crate::sys::signal::SigSet;
|
9 | 7 | #[cfg(feature = "fs")]
|
10 | 8 | use crate::sys::stat::Mode;
|
11 | 9 | use crate::{errno::Errno, unistd::Pid, NixPath, Result};
|
| 10 | +use std::os::fd::AsRawFd; |
| 11 | +use std::{ffi::CStr, mem, os::fd::RawFd}; |
12 | 12 |
|
13 | 13 | /// A spawn attributes object. See [posix_spawnattr_t](https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawnattr_init.html).
|
14 | 14 | #[repr(transparent)]
|
@@ -277,7 +277,14 @@ impl PosixSpawnFileActions {
|
277 | 277 | /// Add a [dup2](https://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html) action. See
|
278 | 278 | /// [posix_spawn_file_actions_adddup2](https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawn_file_actions_adddup2.html).
|
279 | 279 | #[doc(alias("posix_spawn_file_actions_adddup2"))]
|
280 |
| - pub fn add_dup2(&mut self, fd: RawFd, newfd: RawFd) -> Result<()> { |
| 280 | + pub fn add_dup2<Fd, NewFd>(&mut self, fd: Fd, newfd: NewFd) -> Result<()> |
| 281 | + where |
| 282 | + Fd: std::os::fd::AsFd, |
| 283 | + NewFd: std::os::fd::AsFd, |
| 284 | + { |
| 285 | + let fd = fd.as_fd().as_raw_fd(); |
| 286 | + let newfd = newfd.as_fd().as_raw_fd(); |
| 287 | + |
281 | 288 | let res = unsafe {
|
282 | 289 | libc::posix_spawn_file_actions_adddup2(
|
283 | 290 | &mut self.fa as *mut libc::posix_spawn_file_actions_t,
|
|
0 commit comments