fish-shell / fish-shell/fish-shell

Missing job control for commands run with `-C`/`--init-command`/`postconfig_cmds`

Open
#11,581 4 comments 1 reaction 0 assignees View on GitHub
Dominant language
Rust
Stars
34.2k
Forks
2.4k
Avg merge
2d 8h
Merged PRs (30d)
13

Description

- fish versions tested with
- `fish, version 4.0.2` (the version provided by `archlinux`)
- `fish, version 4.0.2-1055-gd67fdd1f0` (current master at time of testing)
- os
- `Linux arch-book 6.14.7-arch2-1`
- terminal
- `alacritty 0.15.1 (0c405d53)`

Running `fish -C 'sleep 5'` and immediately pressing `C-z` suspends fish shell and not `sleep`.
Expected behavior would be for `sleep` to be suspended.

---

My primary usecase is to be able to startup fish with TUIs like `nvim` and being able to freely suspend and switch between them.

My current working hypothesis is that running `fish -C ` does not put `` into the
foreground. More concretely the `tpgid` (foreground process group of the controlling terminal of the
process) is not set to the PID of the running command, but to `fish`'s.
Which means that the terminal driver sends signals meant for the foreground process not the the
running command, but to `fish`.

I have pretty much confirmed this by now by running `ps -o 'pid tpgid s cmd' +` and seeing `fish` is the foreground process of the terminal.

```
$ ps -o 'pid tpgid s cmd' +53796
PID TPGID S CMD
62018 62018 S fish -C nvim
62022 62018 S nvim
```
(`TPGID` is `62018` not `62022`)

where as running `fish` and then manually typing `nvim` + enter has `nvim` set as foreground process
as expected.

```
$ ps -o 'pid tpgid s cmd' +53796
PID TPGID S CMD
63033 63059 S fish
63059 63059 S nvim
```
(`TPGID` is `63059` as expected)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.