title: Libcall() in vim cause new invocation of editor
body: <p>I am writing auxiliary library for vim-xkbswitch plugin in Mac OS X. Goal of plugin is automatic changing of keyboard layouts after exiting from insert mode. I've written simple library for this purpose and everything is fine. But there is a issue. When I am invoking the function for changing of layout, the new icon of editor appears in the dock but it's unresponsive. </p>
  
  <p><img src="https://i.stack.imgur.com/9eNxU.png" alt="New unresponsive icon"></p>
  
  <p>I traced through the code and found that function <code>TISCreateInputSourceList (NULL, false);</code> cause invocation of three new threads.</p>
  
  <p><img src="https://i.stack.imgur.com/0TaUC.png" alt="New threads"></p>
  
  <p>Here is my function for layout switching from library:</p>
  
  <pre><code>// If the application was run with argument(s)
  const char * Xkb_Switch_setXkbLayout( const char * param ) {
      // Get enabled keyboard layouts list
      CFArrayRef sourceList = (CFArrayRef) TISCreateInputSourceList (NULL, false);
      // Get the first argument. It is index of wanted keyboard layout
      int wantedSourceIndex = atoi(param);
      // Get wanted keyboard layout by index
      TISInputSourceRef wantedSource = (TISInputSourceRef) CFArrayGetValueAtIndex(sourceList, wantedSourceIndex);
  
      // If a keyboard layout with the index does not exist
      if (!wantedSource) {
          printf("%d", -1);
      }
  
      // Switch to wanted keyboard layout
      TISSelectInputSource(wantedSource);
      return "";
  }
  </code></pre>