Open
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?
Metadata
Metadata
Assignees
Labels
No labels