Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify pid instead of socket #172

Open
ModProg opened this issue Jan 31, 2022 · 3 comments
Open

Specify pid instead of socket #172

ModProg opened this issue Jan 31, 2022 · 3 comments

Comments

@ModProg
Copy link

ModProg commented Jan 31, 2022

Is it possible to select the nvim instance by PID instead of socket?

I want to query the current state of an instance to decide whether I need to ask before closing a tab in my terminal, but I only have the PID of the nvim process in question.

Is there a convinient way to run the evaluation on the nvim instance with that PID. I was thinking something like:

nvr --process 123456 --remote-expr "getbufinfo({'bufmodified': 1})"
@KillTheMule
Copy link

You could use lsof -p {pid} to find out what files your process has open, and select the socket from that list.

@ModProg
Copy link
Author

ModProg commented Feb 2, 2022

Alright, I'll use lsof -p 133249 | awk '{print $9}' | grep /tmp/nvim for now. Maybe not ideal but should probably be reliable

@joshbode
Copy link

joshbode commented Sep 27, 2022

on my machine, as long as I don't set the NVIM_LISTEN_ADDRESS environment variable (which, while supported by nvr, is deprecated in nvim, but still has an effect on the socket name), the PID is added to the socket, e.g.

$ nvr --serverlist
/run/user/1000/nvim.878819.0

so it is possible to do this if you know the PID:

$ PID=878819
$ nvr --servername "${XDG_RUNTIME_DIR}/nvim.${PID}.0" ...

(the .0 at the end is a counter, but I believe it is incremented only if the same process is serving on multiple sockets)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants