Skip to content

Commit

Permalink
fix:! Don't fork by default (neovide#2512)
Browse files Browse the repository at this point in the history
* Don't fork by default

And, never when a tty is not attached.

* Update the documentation
  • Loading branch information
fredizzimo authored and zbyna committed May 17, 2024
1 parent a7c6f13 commit 7cc925a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
11 changes: 1 addition & 10 deletions src/cmd_line.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::{iter, mem};

use crate::utils::is_tty;
use crate::{dimensions::Dimensions, frame::Frame, settings::*};

use anyhow::Result;
Expand All @@ -24,14 +23,6 @@ fn get_styles() -> Styles {
.placeholder(styling::AnsiColor::Cyan.on_default())
}

fn is_tty_str() -> &'static str {
if is_tty() {
"1"
} else {
"0"
}
}

#[derive(Clone, Debug, Parser)]
#[command(version, about, long_about = None, styles = get_styles())]
pub struct CmdLineSettings {
Expand Down Expand Up @@ -77,7 +68,7 @@ pub struct CmdLineSettings {
pub title_hidden: bool,

/// Spawn a child process and leak it [DEFAULT]
#[arg(long = "fork", env = "NEOVIDE_FORK", action = ArgAction::SetTrue, default_value = is_tty_str(), value_parser = FalseyValueParser::new())]
#[arg(long = "fork", env = "NEOVIDE_FORK", action = ArgAction::SetTrue, default_value = "0", value_parser = FalseyValueParser::new())]
pub fork: bool,

/// Be "blocking" and let the shell persist as parent process. Takes precedence over `--fork`.
Expand Down
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ fn maybe_disown() {

let settings = SETTINGS.get::<CmdLineSettings>();

if cfg!(debug_assertions) || !settings.fork {
// Never fork unless a tty is attached
if !settings.fork || !utils::is_tty() {
return;
}

Expand Down
8 changes: 4 additions & 4 deletions website/docs/command-line-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,14 @@ This disables neovim's multigrid functionality which will also disable floating
backgrounds, smooth scrolling, and window animations. This can solve some issues where neovide
acts differently from terminal neovim.

### No Fork
### Fork

```sh
--no-fork or $NEOVIDE_FORK=0|1
--fork or $NEOVIDE_FORK=0|1
```

By default, neovide detaches itself from the terminal. Instead of spawning a child process and
leaking it, be "blocking" and have the shell directly as parent process.
Detach from the terminal instead of waiting for the Neovide process to
terminate. This parameter has no effect when launching from a GUI.

### No Idle

Expand Down

0 comments on commit 7cc925a

Please sign in to comment.