Browse Source

Fix windows compilation with --no-fork

--no-fork is a stub on windows.
daemonize
Julian Ospald 5 years ago
parent
commit
c7e1ed1af3
No known key found for this signature in database GPG Key ID: 511B62C09D50CD28
2 changed files with 18 additions and 12 deletions
  1. +2
    -0
      Cargo.toml
  2. +16
    -12
      src/main.rs

+ 2
- 0
Cargo.toml 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"


+ 16
- 12
src/main.rs 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();

if want_fork {
daemonize_redirect(Some("/tmp/nvim-gtk_stdout.log"),
Some("/tmp/nvim-gtk_stderr.log"),
ChdirMode::NoChdir)
.unwrap();
#[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();
}
}

app.run(&argv);


Loading…
Cancel
Save