jlebon / textern

A Firefox add-on for editing text in your favourite external editor!
GNU General Public License v3.0
138 stars 21 forks source link

Kill editors on exit #88

Closed phdru closed 1 year ago

phdru commented 1 year ago

Kill editors on exit using setpriv --pdeathsig SIGTERM. Linux-only.

jlebon commented 1 year ago

Thanks! Will try this out soon and then hoping to cut a release.

jlebon commented 1 year ago

OK, finally got around to testing this out in earnest. I'm thinking now that we shouldn't ship this and in fact probably don't need this at all but I'm interested to hear more about your use case. For two reasons:

  1. At this point, it's possible for users to directly configure this today by prefixing their editor command with setpriv --pdeathsig <SIG> (and that in fact gives them the opportunity to choose themselves whether to use SIGTERM or SIGKILL).
  2. There are commonplace cases where this does not work as intended: a. Flatpak-based editors use bubblewrap which sets up multiple processes as part of its sandboxing. Killing the parent (monitor) process does not also kill the child (editor) process. There's a builtin flatpak run -p option to do this correctly though (by using prctl(PR_SET_PDEATHSIG) on both the parent and the child processes). b. Terminal editors launched via GNOME Terminal run into the fact that gnome-terminal actually just calls out to gnome-terminal-server which is what owns the editor process. So killing gnome-terminal in this case won't actually affect the editor process. I'm not sure what other terminal emulators fall in this category.

WDYT instead about turning this into a docs PR documenting the setpriv prefix (would have to include caveats) and the flatpak run -p option?

phdru commented 1 year ago

I'm thinking now that we shouldn't ship this

Ok.

WDYT instead about turning this into a docs PR documenting the setpriv prefix

Sure, go on.