zsh-workers
 help / color / mirror / code / Atom feed
* Weird bug / missing feature with gvim interaction
@ 2023-03-06  1:32 Felipe Contreras
  2023-03-06  4:28 ` Bart Schaefer
  2023-03-06 15:14 ` lilydjwg
  0 siblings, 2 replies; 8+ messages in thread
From: Felipe Contreras @ 2023-03-06  1:32 UTC (permalink / raw)
  To: Zsh hackers list

Hi,

I've been investigating for a while a weird interaction with vim and
zsh, and this is the closest I've gotten to narrowing down the
problem.

Essentially this doesn't work:

    vim -g -c 'set shelltemp' -c ':!xdg-open "https://google.com"'

The reason it doesn't work is that xdg-open immediately spawns a fork,
which is why this doesn't work either:

    vim -g -c 'set shelltemp' -c ':!touch /tmp/fork-cur &'

But that actually works in bash.

The two key lines of code from vim are:

    setsid();
    ioctl(slave, TIOCSCTTY, NULL);

If I remove those, the code works fine, but then it doesn't work with sudo:

    vim -g -c 'set shelltemp' -c ':!sudo touch /tmp/sudo &'

But it does with bash.

It is a bit overwhelming, since there are many combinations:

    {bash,zsh}{sudo,fork}{sid,}

But long story short, there's a combination that works with bash, but
there isn't a single one that works with zsh.

I wrote a program to be able to test this behavior outside of vim, and
I can reproduce the problem [1].

The two combinations that don't work with zsh are:

1. sudo without setsid (the program cannot feed input into sudo)
2. fork with setsid (the grandchilds are sent SIGHUP)

This is beyond my expertise, but I've tried my best to narrow down the problem.

Is there any way to solve this in zsh?

Cheers.

[1] https://gist.githubusercontent.com/felipec/8a820f3dbf67a5861491553e211400fb/raw/e7f537c0b5b5f4d742f90cfac5f7f046ea61d438/pty-test.c

-- 
Felipe Contreras


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-03-06 19:47 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-06  1:32 Weird bug / missing feature with gvim interaction Felipe Contreras
2023-03-06  4:28 ` Bart Schaefer
2023-03-06  4:32   ` Bart Schaefer
2023-03-06 14:31   ` Felipe Contreras
2023-03-06 19:35     ` Bart Schaefer
2023-03-06 19:47       ` Felipe Contreras
2023-03-06 15:14 ` lilydjwg
2023-03-06 15:54   ` Felipe Contreras

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).