On Thu, Jul 23, 2020 at 09:57:25PM +0200, Tassilo Horn wrote:
> Hi all,
> 
> say I have the following script:
> 
> --8<---------------cut here---------------start------------->8---
> #!/bin/env fish
> 
> function on_SIGINT --on-signal SIGINT
>     echo "Got SIGINT!"
> end
> 
> epiphany
> --8<---------------cut here---------------end--------------->8---
> 
> When I run it, it just opens the epiphany browser in the foreground,
> i.e., the call to epiphany won't return before it's quit.
> 
> Now I type C-c in the terminal.  I had expected that "Got SIGINT!" be
> echoed but that doesn't happen.  So what am I doing wrong?  I've tried
> the same with SIGTERM and SIGKILL.

You're doing nothing wrong - apparently non-interactive INT handlers
have never worked in fish, see:

https://github.com/fish-shell/fish-shell/issues/6649

In an interactive session, it kind of works

        function on_SIGINT --on-signal SIGINT
            echo "Got SIGINT!"
        end
        while true; echo press ctrl-c; end

However, when an external program is running, the handlers don't seem to work.
When replacing the while loop with "sleep 10", the signal handler is not
run on ^C.

Of course we want to improve non-interactive fish but for now I'd stick with
a POSIX shell for this task.

> My actual use-case is a script that will eventually call openconnect to
> establish a VPN connection to my work network.  During my work day, I'll
> mount several samba shares from that network and usually I forget to
> umount them before C-c-ing the script.  Then the system shutdown will
> hang because the system tries to umount them which won't work without
> VPN connection.  So I want some mechanism to umount those shares
> _before_ the VPN connection is closed.

Suspend or hibernate in place of a full shutdown might avoid this problem.

Integrating the scripts in your system's service manager seems like the
proper solution. By specifying the mounts' dependency on openconnect this
could probably be automated nicely.


> 
> I'm running fish 3.1.2.
> 
> Thanks for any pointers,
> Tassilo
> 
> 
> 
> _______________________________________________
> Fish-users mailing list
> Fish-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/fish-users


_______________________________________________
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to