Skip to content

Starting fish background job in an event/variable handler borks commandline for duration of job #7842

Closed

Description

@IlanCosman

fish, version 3.2.1-5-gd79f86407
Tested on MacOS and Arch

not-highlighting.mp4
function on_foo --on-event foo
    fish --command "sleep 3" &
end

Syntax highlighting will be disabled for the full duration of the background job, i.e if you replace sleep 3 with sleep 10 it'll take 10 seconds to come back instead.

This also happens with --on-variable, and I presume all other handlers though I haven't tested them.

Interestingly this bug doesn't appear when running other commands such as sleep or kill, it only seems to work with fish.

Not sure if this is a regression.

Activity

  1. changed the title [-]Starting fish background job in an event/variable handler disables highlighting for duration of job[/-] [+]Starting fish background job in an event/variable handler borks commandline for duration of job[/+] on Mar 21, 2021
  2. added
    regressionSomething that used to work, but was broken, especially between releases
    on Mar 21, 2021
  3. added this to the fish 3.3.0 milestone on Mar 21, 2021
  4. IlanCosman commented on Mar 21, 2021

    @IlanCosman
    ContributorAuthor

    @faho Is there anything I can do right now with fish script to remove this problem? Fish 3.3 might be a while and this is an annoying bug in my project 😄

  5. faho commented on Mar 22, 2021

    @faho
    Member

    @IlanCosman I'll leave you in the capable hands of the others, I'm taking a break.

  6. IlanCosman commented on Mar 23, 2021

    @IlanCosman
    ContributorAuthor

    @ridiculousfish 😅 Sorry to bother, but would you happen to know a fancy Fish trick to get around this?

  7. krobelus commented on Mar 23, 2021

    @krobelus
    Contributor

    @IlanCosman on Linux you can use setsid to launch the background fish in a new process group.
    Since it doesn't own the terminal 013a563 does the job.

    function on_foo --on-event foo
        setsid fish --command "sleep 3" &
    end

    I'm not sure about which portable solution is best. Apparently nohup works as well instead of setsid.

  8. IlanCosman commented on Mar 25, 2021

    @IlanCosman
    ContributorAuthor

    Huh, it seems simply setting status job-control full fixes this. Sick!

  9. faho commented on Mar 26, 2021

    @faho
    Member

    Huh, it seems simply setting status job-control full fixes this. Sick!

    @IlanCosman That is emphatically not a knob you want to touch (to be honest it should not exist to begin with, but we're working on that).

    Instead simply set the background process's stdin to /dev/null:

        fish --command "sleep 3" </dev/null &

    Since the issue is that fish only checks if the group controlling the stdin terminal is its group, just make it so that stdin isn't a terminal.

  10. IlanCosman commented on Mar 26, 2021

    @IlanCosman
    ContributorAuthor

    Thanks a ton @faho! Yah, setting the job-control was a bit sketchy, I noticed it was setting the user's last_pid outside of Tide but decided that minimal risk was an ok tradeoff.

    This is why you can't take a break Fabian, I need you too much ❤️😂

  11. added a commit that references this issue on Mar 28, 2021
  12. added
    bugSomething that's not working as intended
    and removed
    regressionSomething that used to work, but was broken, especially between releases
    on Apr 1, 2021
  13. zanchey commented on Apr 1, 2021

    @zanchey
    Member

    This reproduces for me in 3.2.1, so I don't think it's a regression.

  14. faho commented on Apr 1, 2021

    @faho
    Member

    It's a regression from 3.2.0, caused by 013a563

  15. modified the milestones: fish 3.3.0, fish 3.2.2 on Apr 1, 2021
  16. zanchey commented on Apr 1, 2021

    @zanchey
    Member

    OK, I'd prefer to keep the regression tag for "things that aren't in a release" as it means I can skip over them for the release notes.

  17. added 2 commits that reference this issue on Apr 1, 2021
    9221a3d
    92c2829
  18. locked as resolved and limited conversation to collaborators on Sep 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething that's not working as intended

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions