help / color / mirror / code / Atom feed
From: Felipe Contreras <felipe.contreras@gmail.com>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: Weird bug / missing feature with gvim interaction
Date: Mon, 6 Mar 2023 13:47:11 -0600	[thread overview]
Message-ID: <CAMP44s2BZoMBBmp8ofZ2vWKkOp-nWTSjDfDmjnAVZ03NphSS9w@mail.gmail.com> (raw)
In-Reply-To: <CAH+w=7ZfgisfnsRFH=ud_zB9BCjcv9=wS19QvtcPTN1rJsq-3w@mail.gmail.com>

On Mon, Mar 6, 2023 at 1:35 PM Bart Schaefer <schaefer@brasslantern.com> wrote:
> On Mon, Mar 6, 2023 at 6:31 AM Felipe Contreras
> <felipe.contreras@gmail.com> wrote:
> >
> > On Sun, Mar 5, 2023 at 10:28 PM Bart Schaefer <schaefer@brasslantern.com> wrote:
> > >
> > > What's not clear is where the HUP is coming from
> > >
> > > Puzzlingly, using "nohup xdg-open ..." doesn't help.
> >
> > That doesn't help, but "setsid nohup xdg-open ..." does help, both in
> > bash and zsh. But I believe that's what the vim code essentially tried
> > to do.
> Sure, but vim is doing it before zsh starts up, whereas when you use
> the setsid command it creates the new process group after zsh runs it.
> E.g., without the setsid command, I believe the thread would be that
> zsh execs nohup which execs xdg-open, all with no forking involved,
> but if you add setsid in front then zsh execs setsid which forks
> before exec of nohup.
> Zsh doesn't use setsid(2) and doesn't mess with the process group by
> any other means unless there's a controlling tty to attach to, which
> there presumably is not in this case.
> Still doesn't explain the source of the HUP signal, or why nohup fails
> to ignore it ... unless xdg-open is deliberately unblocking it again.

I believe that's what happens because GLib's g_spawn_async does
something like that.

When I hunted the code down I believe it does something like this:

#include <spawn.h>
#include <signal.h>

extern char **environ;

int main(void)
char *const argv[] = { "/usr/bin/chromium", "http://google.com", NULL };
posix_spawnattr_t attr;
sigset_t mask;

sigaddset(&mask, SIGHUP);

posix_spawnattr_setsigdefault(&attr, &mask);
posix_spawnattr_setflags(&attr, POSIX_SPAWN_SETSIGDEF);

return posix_spawn(NULL, argv[0], NULL, &attr, argv, environ);

Felipe Contreras

  reply	other threads:[~2023-03-06 19:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-06  1:32 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 [this message]
2023-03-06 15:14 ` lilydjwg
2023-03-06 15:54   ` Felipe Contreras

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAMP44s2BZoMBBmp8ofZ2vWKkOp-nWTSjDfDmjnAVZ03NphSS9w@mail.gmail.com \
    --to=felipe.contreras@gmail.com \
    --cc=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox


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).