1
0
Fork 0
mirror of https://github.com/alacritty/alacritty.git synced 2024-11-18 13:55:23 -05:00

Fix macos subprocess execution

This fixes the execution of subprocesses on macOS which could sometimes
prevent actions like `SpawnNewProcess` or custom commands from launching
their processes correctly.

This fixes #2259.
This commit is contained in:
Christian Duerr 2019-04-11 08:41:20 +00:00 committed by GitHub
parent 3478676f8f
commit aac62ce5ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 5 deletions

View file

@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Reset scrolling region when the RIS escape sequence is received
- Subprocess spawning on macos
## Version 0.3.0

View file

@ -13,7 +13,7 @@
// limitations under the License.
use std::ffi::OsStr;
use std::process::Command;
use std::process::{Command, Stdio};
use std::{cmp, io};
#[cfg(not(windows))]
@ -22,8 +22,6 @@ use std::os::unix::process::CommandExt;
#[cfg(windows)]
use std::os::windows::process::CommandExt;
#[cfg(windows)]
use std::process::Stdio;
#[cfg(windows)]
use winapi::um::winbase::{CREATE_NEW_PROCESS_GROUP, CREATE_NO_WINDOW};
/// Threading utilities
@ -91,9 +89,20 @@ where
{
Command::new(program)
.args(args)
.stdin(Stdio::null())
.stdout(Stdio::null())
.stderr(Stdio::null())
.before_exec(|| unsafe {
#[allow(deprecated)]
libc::daemon(1, 0);
match ::libc::fork() {
-1 => return Err(io::Error::last_os_error()),
0 => (),
_ => ::libc::_exit(0),
}
if ::libc::setsid() == -1 {
return Err(io::Error::last_os_error());
}
Ok(())
})
.spawn()?