Hi Bastien!

On Sa, 10 Mär 2012, Bastien Dejean wrote:

> Taylor Hedberg:
> 
> > Bastien Dejean, Fri 2012-03-09 @ 11:30:17+0100:
> > > I'd like vim to reload its configuration after receiving SIGUSR1.
> > > It that possible?
> > 
> > Pretty sure you'd have to patch Vim's source code for this. There's no
> > way that I know of to install a POSIX signal handler from within a Vim
> > script.
> 
> I made a patch (attached) and it fails.
> Any hints?
> 
> Greetings,

> diff -ru vim-7.3.434/src/os_unix.c vim_usr1_reload/src/os_unix.c
> --- vim-7.3.434/src/os_unix.c 2012-02-09 22:09:00.000000000 +0100
> +++ vim_usr1_reload/src/os_unix.c     2012-03-10 14:23:02.774469698 +0100
> @@ -305,7 +305,7 @@
>      {SIGXFSZ,            "XFSZ",     TRUE},
>  #endif
>  #ifdef SIGUSR1
> -    {SIGUSR1,            "USR1",     TRUE},
> +    {SIGUSR1,            "USR1",     FALSE},
>  #endif
>  #if defined(SIGUSR2) && !defined(FEAT_SYSMOUSE)
>      /* Used for sysmouse handling */
> @@ -1105,6 +1105,17 @@
>      SIGRETURN;
>  }
>  
> +#if defined(SIGUSR1)
> +    static RETSIGTYPE
> +reload_config SIGDEFARG(sigarg)
> +{
> +#ifdef USR_VIMRC_FILE
> +    (void)do_source((char_u *)USR_VIMRC_FILE, FALSE, DOSO_NONE);
> +#endif
> +    SIGRETURN;
> +}
> +#endif
> +
>  #if defined(_REENTRANT) && defined(SIGCONT)
>  /*
>   * On Solaris with multi-threading, suspending might not work immediately.
> @@ -1264,6 +1275,13 @@
>  #endif
>  
>      /*
> +     * Reload configuration on SIGUSR1
> +     */
> +#ifdef SIGUSR1
> +    signal(SIGUSR1, reload_config);
> +#endif
> +
> +    /*
>       * Catch SIGPWR (power failure?) to preserve the swap files, so that no
>       * work will be lost.
>       */

seems to work here.


regards,
Christian
-- 
Student telegrafiert seinem Vater: Schicke Geld - Dein Sohn
Vater telegrafiert zurück: Habe keins erhalten - Dein Vater

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to