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

fish_exit doesn't fire when terminal window is closed #7014

Closed
andreiborisov opened this issue May 18, 2020 · 5 comments
Closed

fish_exit doesn't fire when terminal window is closed #7014

andreiborisov opened this issue May 18, 2020 · 5 comments
Labels
bug Something that's not working as intended
Milestone

Comments

@andreiborisov
Copy link

andreiborisov commented May 18, 2020

Function defined as

function my_function --on-event fish_exit
end

doesn't fire when Terminal.app (or iTerm) window is closed on macOS.

Is this expected behavior? If so, how can I fire my_function when the terminal window is closed?

I've also tried:
--on-process-exit $fish_pid
--on-signal SIGTERM
--on-signal SIGKILL

No success.

P.S. my_function is fired after executing exit command in the terminal window, but I need to be able to run it when the window is closed too.

fish, version 3.1.2
macOS 10.15.4
Terminal.app 2.10
@andreiborisov andreiborisov changed the title fish_exit doesn't fire when Terminal window is closed fish_exit doesn't fire when terminal window is closed May 18, 2020
@faho
Copy link
Member

faho commented May 18, 2020

What exactly are you doing? What function are you using?

E.g. if I do

function idea --on-event fish_exit
    date >> /tmp/idied
end

that leaves a timestamp in the file /tmp/idied in my tests. This is on linux, so it's possible there's some macOS weirdness.

@zanchey
Copy link
Member

zanchey commented May 19, 2020

The event doesn't work for me on macOS or Linux when fish receives the SIGHUP signal, such as by kill-window in tmux or similar. Running through the debugger shows the event firing, but not the external process starting.

@zanchey zanchey added the bug Something that's not working as intended label May 19, 2020
@zanchey zanchey added this to the fish-future milestone May 19, 2020
@andreiborisov
Copy link
Author

andreiborisov commented May 19, 2020

@faho thank you for your answer!☺️

It does not seem to be related to a particular function I'm using because your example doesn't work for me either.

@mqudsi

This comment has been minimized.

@mqudsi
Copy link
Contributor

mqudsi commented Jul 5, 2020

When SIGHUP is encountered, a flag is set to end the read loop (s_exit_forced). No new executions are allowed through when this flag is present, and it's set before the fish_exit event is fired. As @zanchey says, the event is fired but nothing is executed.

@mqudsi mqudsi closed this as completed in 04c6442 Jul 6, 2020
@zanchey zanchey modified the milestones: fish-future, fish 3.2.0 Jul 8, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something that's not working as intended
Projects
None yet
Development

No branches or pull requests

4 participants