mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 03:05:11 -07:00
parent
8bdcd832ae
commit
b2cb05b53e
@ -870,7 +870,7 @@ ShellCmdPost After executing a shell command with |:!cmd|,
|
||||
*Signal*
|
||||
Signal After Nvim receives a signal. The pattern is
|
||||
matched against the signal name. Only
|
||||
"SIGUSR1" is supported. Example: >
|
||||
"SIGUSR1" and "SIGWINCH" are supported. Example: >
|
||||
autocmd Signal SIGUSR1 call some#func()
|
||||
< *ShellFilterPost*
|
||||
ShellFilterPost After executing a shell command with
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "nvim/os/signal.h"
|
||||
#include "nvim/vim.h"
|
||||
|
||||
static SignalWatcher spipe, shup, squit, sterm, susr1;
|
||||
static SignalWatcher spipe, shup, squit, sterm, susr1, swinch;
|
||||
#ifdef SIGPWR
|
||||
static SignalWatcher spwr;
|
||||
#endif
|
||||
@ -53,6 +53,9 @@ void signal_init(void)
|
||||
#endif
|
||||
#ifdef SIGUSR1
|
||||
signal_watcher_init(&main_loop, &susr1, NULL);
|
||||
#endif
|
||||
#ifdef SIGWINCH
|
||||
signal_watcher_init(&main_loop, &swinch, NULL);
|
||||
#endif
|
||||
signal_start();
|
||||
}
|
||||
@ -70,6 +73,9 @@ void signal_teardown(void)
|
||||
#ifdef SIGUSR1
|
||||
signal_watcher_close(&susr1, NULL);
|
||||
#endif
|
||||
#ifdef SIGWINCH
|
||||
signal_watcher_close(&swinch, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
void signal_start(void)
|
||||
@ -88,6 +94,9 @@ void signal_start(void)
|
||||
#ifdef SIGUSR1
|
||||
signal_watcher_start(&susr1, on_signal, SIGUSR1);
|
||||
#endif
|
||||
#ifdef SIGWINCH
|
||||
signal_watcher_start(&swinch, on_signal, SIGWINCH);
|
||||
#endif
|
||||
}
|
||||
|
||||
void signal_stop(void)
|
||||
@ -106,6 +115,9 @@ void signal_stop(void)
|
||||
#ifdef SIGUSR1
|
||||
signal_watcher_stop(&susr1);
|
||||
#endif
|
||||
#ifdef SIGWINCH
|
||||
signal_watcher_stop(&swinch);
|
||||
#endif
|
||||
}
|
||||
|
||||
void signal_reject_deadly(void)
|
||||
@ -140,6 +152,10 @@ static char *signal_name(int signum)
|
||||
#ifdef SIGUSR1
|
||||
case SIGUSR1:
|
||||
return "SIGUSR1";
|
||||
#endif
|
||||
#ifdef SIGWINCH
|
||||
case SIGWINCH:
|
||||
return "SIGWINCH";
|
||||
#endif
|
||||
default:
|
||||
return "Unknown";
|
||||
@ -197,6 +213,12 @@ static void on_signal(SignalWatcher *handle, int signum, void *data)
|
||||
apply_autocmds(EVENT_SIGNAL, (char_u *)"SIGUSR1", curbuf->b_fname, true,
|
||||
curbuf);
|
||||
break;
|
||||
#endif
|
||||
#ifdef SIGWINCH
|
||||
case SIGWINCH:
|
||||
apply_autocmds(EVENT_SIGNAL, (char_u *)"SIGWINCH", curbuf->b_fname, true,
|
||||
curbuf);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
ELOG("invalid signal: %d", signum);
|
||||
|
@ -30,6 +30,12 @@ describe('autocmd Signal', function()
|
||||
eq({'notification', 'foo', {}}, next_msg())
|
||||
end)
|
||||
|
||||
it('matches SIGWINCH', function()
|
||||
command('autocmd Signal SIGWINCH call rpcnotify(1, "foo")')
|
||||
posix_kill('WINCH', funcs.getpid())
|
||||
eq({'notification', 'foo', {}}, next_msg())
|
||||
end)
|
||||
|
||||
it('does not match unknown patterns', function()
|
||||
command('autocmd Signal SIGUSR2 call rpcnotify(1, "foo")')
|
||||
posix_kill('USR1', funcs.getpid())
|
||||
|
Loading…
Reference in New Issue
Block a user