Job keeps running after neovim exits
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- lua
- Domain
- operating-systems
Research direction
Start by inspecting the plenary.job entry points used here: Job:new, j:start(), and the detach option. Reproduce the process-parent behavior on Neovim exit, then trace how job cleanup is handled and verify that a non-detached job exits with Neovim rather than being reparented.
Written by the indexing model from the issue text.
Description
I have an external program I want to run that runs forever, and very rarely prints a thing on stdout I want to handle.
This works all works fine
local Job = require("plenary.job")
local j = Job:new({
command = "/path/to/my/thing",
on_stdout = function(_, msg)
process(msg)
end
end,
})
j:start()
and starts the external process with the parent being neovim as I would expect.
~> ps -l -p 43471,43782
UID PID PPID F CPU PRI NI SZ RSS WCHAN S ADDR TTY TIME CMD
501 43471 43334 4006 0 31 0 5525556 42416 - S+ 0 ttys000 0:01.56 nvim test.lua
501 43782 43471 4006 0 31 0 4560568 9424 - S+ 0 ttys000 0:00.05 /path/to/my/thing
However, when I quit neovim, the external process is not stopped, and it's parent has changed to 1
~> ps -l -p 43471,43782
UID PID PPID F CPU PRI NI SZ RSS WCHAN S ADDR TTY TIME CMD
501 43782 1 4006 0 31 0 4560568 9424 - S 0 ttys000 0:00.05 /path/to/my/thing
I'm not using the detach flag on job, so I expected the process to die when the parent process died.
I suppose I could register an autocomand to do something at vim exit (maybe? I'm just assuming there is an autocommand for that but don’t know what it is or if it exists for real), but that seems hacky. Is there another way to get this process to automatically exit when neovim itself exists?
- Dominant language
- Lua
- Stars
- 3.5k
- Forks
- 340
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nvim-lua/plenary.nvim
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
nvim-lua/plenary.nvim#682 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
nvim-lua/plenary.nvim#680 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
nvim-lua/plenary.nvim#675 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 28/100
nvim-lua/plenary.nvim#672 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
nvim-lua/plenary.nvim#671 · 1 comment ·
All issues in nvim-lua/plenary.nvim
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
[Eco] Egg Config Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
pterodactyl/game-eggs#634 ·
-
Feature Request
Difficulty 1/5 Under an hour Newbie friendliness 72/100
Questie/QuestieTrace#33 ·