Is :! buggy?

12 views
Skip to first unread message

Felipe Contreras

unread,
May 30, 2021, 9:54:41 PM5/30/21
to vim...@vim.org
Hello,

If I run this:

:call system('exo-open http://google.com')

It works fine.

But this doesn't:

:!exo-open http://google.com

I tried to reproduce what exo-open ultimately does, an the issue ends up
with a simple g_spawn_async().

#include <glib.h>

int main(void)
{
gchar *argv[] = { "/usr/bin/brave", "http://google.com", NULL };
g_spawn_async (NULL, argv, NULL, 0, NULL, NULL, NULL, NULL);
return 0;
}

The program ends too quickly and nothing happens, but only with :!

Oh, and this only happens in gvim, not in vim.

Is there a bug with :! not present with system()?

Cheers.

--
Felipe Contreras

Christian Brabandt

unread,
May 31, 2021, 1:36:47 AM5/31/21
to vim...@vim.org

On So, 30 Mai 2021, Felipe Contreras wrote:

> Hello,
>
> If I run this:
>
> :call system('exo-open http://google.com')
>
> It works fine.
>
> But this doesn't:
>
> :!exo-open http://google.com
>
> I tried to reproduce what exo-open ultimately does, an the issue ends up
> with a simple g_spawn_async().

I have seen this behaviour before, but not sure what is causing this. It
works using `setsid xdg-open` as mentioned e.g. here:
https://vi.stackexchange.com/a/5034/71

I have also created a bug report against exo-open, but that one was
shutdown without much discussion :(

Note: emacs seems to have a similar problem, this answer goes a bit more
into the details why this may happen:
https://askubuntu.com/a/675366/855670


Best
Christian
--
Verwechsle nicht die Freude am Gefallen mit dem Glück der Liebe.
-- Coco Chanel

Felipe Contreras

unread,
May 31, 2021, 3:37:41 AM5/31/21
to vim_dev
Please CC me. I don't receive messages from the list.

On Monday, May 31, 2021 at 12:36:47 AM UTC-5 cbl...@256bit.org wrote:
I have seen this behaviour before, but not sure what is causing this. It
works using `setsid xdg-open` as mentioned e.g. here:
https://vi.stackexchange.com/a/5034/71

I found the issue and sent a patch. The problem is that gvim (not vim) is making the child be the controlling tty, when there's no need for that.

There's a workaround to make "!xterm&" work, but that's by ignoring SIGHUP. If the child resets SIGHUP the issue returns, and that's what happens with exo-open (or anything that uses Glib's g_spawn).

Curiously that code is only enabled when shelltemp is on. Disable shelltemp and it works fine.
 
I have also created a bug report against exo-open, but that one was
shutdown without much discussion :(

Yes, I saw it, but they are right; the problem is gvim.
 
Note: emacs seems to have a similar problem, this answer goes a bit more
into the details why this may happen:
https://askubuntu.com/a/675366/855670

They probably set TIOCSCTTY to make the child control the tty as well.

Cheers.
Reply all
Reply to author
Forward
0 new messages