Fix windows compilation with --no-fork

--no-fork is a stub on windows.
This commit is contained in:
Julian Ospald 2018-06-16 11:11:27 +02:00
parent 53cde1c2b8
commit c7e1ed1af3
No known key found for this signature in database
GPG Key ID: 511B62C09D50CD28
2 changed files with 17 additions and 11 deletions

View File

@ -36,6 +36,8 @@ regex = "0.2"
lazy_static = "1.0"
unicode-width = "0.1.4"
unicode-segmentation = "1.2.0"
[target.'cfg(unix)'.dependencies]
unix-daemonize = "0.1"
serde = "1.0"

View File

@ -1,5 +1,6 @@
#![windows_subsystem = "windows"]
#[cfg(unix)]
extern crate unix_daemonize;
extern crate cairo;
extern crate env_logger;
@ -64,6 +65,7 @@ mod file_browser;
mod subscriptions;
mod misc;
#[cfg(unix)]
use unix_daemonize::{daemonize_redirect, ChdirMode};
use std::env;
use std::io::Read;
@ -114,18 +116,20 @@ fn main() {
.filter(|a| !a.starts_with(NO_FORK))
.collect();
// fork to background by default
let want_fork = env::args()
.take_while(|a| *a != "--")
.skip(1)
.find(|a| a.starts_with(NO_FORK))
.is_none();
#[cfg(unix)] {
// fork to background by default
let want_fork = env::args()
.take_while(|a| *a != "--")
.skip(1)
.find(|a| a.starts_with(NO_FORK))
.is_none();
if want_fork {
daemonize_redirect(Some("/tmp/nvim-gtk_stdout.log"),
Some("/tmp/nvim-gtk_stderr.log"),
ChdirMode::NoChdir)
.unwrap();
if want_fork {
daemonize_redirect(Some("/tmp/nvim-gtk_stdout.log"),
Some("/tmp/nvim-gtk_stderr.log"),
ChdirMode::NoChdir)
.unwrap();
}
}
app.run(&argv);