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

resurrect-processes does not play well with tmux split-window <cmd> #517

Open
jyn514 opened this issue Aug 13, 2024 · 3 comments · May be fixed by #518
Open

resurrect-processes does not play well with tmux split-window <cmd> #517

jyn514 opened this issue Aug 13, 2024 · 3 comments · May be fixed by #518

Comments

@jyn514
Copy link

jyn514 commented Aug 13, 2024

reproduction steps:

  1. open a new session of tmux
  2. run tmux split-window vim
  3. save the session (e.g.<prefix> C-s)
  4. exit the session with tmux kill-server
  5. enter a new session
  6. restore the session (e.g. <prefix> C-r)

the pane containing the command is correctly restored, but the process running inside it is not. this is especially confusing when resurrect-capture-pane-contents is enabled, as it looks like the process is running, but it's not.
image

@jyn514
Copy link
Author

jyn514 commented Aug 13, 2024

here is the contents of the state file:

; cat /home/jyn/.local/share/tmux/resurrect/tmux_resurrect_20240813T184703.txt
pane    3       0       1       :*      0       pop-os  :/home/jyn/src/tmux     0       zsh     :
pane    3       0       1       :*      1       pop-os  :/home/jyn/src/tmux     1       vi      :
window  3       0       :tmux (vi)      1       :*      b187,174x42,0,0[174x21,0,0,4,174x20,0,22,5]     :
state   3

it looks like pane_full_command isn't being saved properly, even though pane_command is correct?

@jyn514
Copy link
Author

jyn514 commented Aug 13, 2024

it turns out the ps.sh save strategy doesn't work, because ps -a ignores processes without an associated terminal. if i replace full_command with this script:

ps  --ppid ${PANE_PID} -o args | tail -n +2

then everything works fine. i'll make a PR with that change.

@jyn514
Copy link
Author

jyn514 commented Aug 13, 2024

hmm. no, it's a little more complicated than that. my fix there only works if you pass the script the PID of the tmux server. but when restoring, resurrect needs to know the PID running in that pane, it can't indiscriminately spawn every process at once. the way it normally does that is to take the output of tmux list-panes -F "#{pane_pid}" and look for all the children of that process with a controlling terminal, because that process is normally a shell. but in this case it's not a shell, it's a regular editor, so it has no children.

i am not quite sure what the correct fix is. maybe if there are no children with a controlling terminal, we can fall back to the parent process?

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

Successfully merging a pull request may close this issue.

1 participant