Skip to content

Background processes spawned by BashExecSilently0 are killed on exit only when xplr runs directly under a terminal #764

@LordMZTE

Description

@LordMZTE

The Issue

Consider this init.lua:

version = '1.0.1'
xplr.config.modes.builtin.go_to.key_bindings.on_key["x"] = {
    help = "open externally",
    messages = {
        {
            BashExecSilently0 = [[
                while IFS= read -r -d '' PTH; do
                    xdg-open "${PTH:?}" > /dev/null 2>&1 &
                    disown
                done < "${XPLR_PIPE_RESULT_OUT:?}"
            ]]
        },
        "PopMode",
    },
}

Which slightly modifies the gx keybind in order to run xdg-open as a background process by using
& and disown.

When we open a terminal, type xplr into the shell and then use gx to open a file externally,
some external program will open separately and stay open even when we quit xplr and then exit the
terminal as expected. However, when we open xplr directly in a terminal by passing the command to
run directly to the terminal emulator, then open some file externally and then exit xplr (which will
now immediately close the terminal too, as there is no shell), the external program will be killed.

External programs I've tried:

  • Zathura for a pdf file
  • nsxiv for a png file

Terminal emulators I've tried:

  • foot xplr -c init.lua
  • xterm -e "xplr -c init.lua"
  • ghostty -e xplr -c init.lua

All exhibit this behavior.

As I can reproduce this across such a wide variety of terminals and external programs, I suspect
that it's some issue with xplr or perhaps my configuration. It might also be some other factor I'm
unaware of (sytemd messing with things, maybe?).

System Information

  • OS: NixOS on nixos-unstable-small
  • xplr: version 1.0.1 from nixpkgs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions