unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: Sarah Morgensen via Bug reports for GNU Guix <bug-guix@gnu.org>
To: Anadon <joshua.r.marshall.1991@gmail.com>
Cc: 49613@debbugs.gnu.org
Subject: bug#49613: On WSL1/2, guix install: error: cannot kill processes for uid `999': failed with exit code 1
Date: Sat, 17 Jul 2021 21:20:25 -0700	[thread overview]
Message-ID: <86lf64tfqu.fsf@mgsn.dev> (raw)
In-Reply-To: <CAFkJGRf3j3=bHQ305xGO6pFiF9KRxKUnsdHH7Aib5PVrS+hF_Q@mail.gmail.com> (Anadon's message of "Sat, 17 Jul 2021 19:30:10 -0400")

Hello Guix,

Anadon <joshua.r.marshall.1991@gmail.com> writes:

> Talking with iskarian on IRC, we've confirmed that guix successfully
> installs, almost successfully sets up (the init.d isn't set up to
> actually daemonize), but for `guix build`, `guix install` and `guix
> pull` all fail with "guix <SUB_CMD>: error: cannot kill processes for
> uid `998': failed with exit code 1" when using WSL1/2.

I've investigated this a bit and it seems to be an issue with the return
code from `kill` when no other processes owned by that user exist to
kill. If I set a process to continually spawn with uid 998, I no longer
encounter the above error. Also, if there is a zombie process under that
uid, I no longer encounter the above error until I manually kill it.
This is on WSL1; I do not know if this technique also applies to WSL2.

For reference, the relevant portion of `nix/libutil/util.cc`:

--8<---------------cut here---------------start------------->8---
    Pid pid = startProcess([&]() {

        if (setuid(uid) == -1)
            throw SysError("setting uid");

        while (true) {
#ifdef __APPLE__
            /* OSX's kill syscall takes a third parameter that, among
               other things, determines if kill(-1, signo) affects the
               calling process. In the OSX libc, it's set to true,
               which means "follow POSIX", which we don't want here
                 */
            if (syscall(SYS_kill, -1, SIGKILL, false) == 0) break;
#elif __GNU__
            /* Killing all a user's processes using PID=-1 does currently
               not work on the Hurd.  */
            if (kill(getpid(), SIGKILL) == 0) break;
#else
            if (kill(-1, SIGKILL) == 0) break;
#endif
            if (errno == ESRCH) break; /* no more processes */
            if (errno != EINTR)
                throw SysError(format("cannot kill processes for uid `%1%'") % uid);
        }

        _exit(0);
    });

    int status = pid.wait(true);
#if __GNU__
    /* When the child killed itself, status = SIGKILL.  */
    if (status == SIGKILL) return;
#endif
    if (status != 0)
        throw Error(format("cannot kill processes for uid `%1%': %2%") % uid % statusToString(status));
--8<---------------cut here---------------end--------------->8---

Perhaps the way WSL handles the return code for ``kill` is not as
expected? On a cursory inspection, though, the relevant parts of WSL2's
kernel/signal.c seem the same as the vanilla Linux kernel...

Or perhaps for some reason `kill(-1, SIGKILL)` under WSL is attempting
to kill the calling process (why?) and failing, therefore returning an
error.

Note that the error code 1 reported by Guix does not seem to be the
actual errno reported by `kill`.

I've seen Guix working on WSL2 in the wild before [0] so this is a
really odd error. I'm stumped.

[0] https://github.com/giuliano108/guix-packages/blob/master/notes/Guix-on-WSL2.md

--
Sarah




      reply	other threads:[~2021-07-18  4:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-17 23:30 bug#49613: On WSL1/2, guix install: error: cannot kill processes for uid `999': failed with exit code 1 Anadon
2021-07-18  4:20 ` Sarah Morgensen via Bug reports for GNU Guix [this message]

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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

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

  git send-email \
    --in-reply-to=86lf64tfqu.fsf@mgsn.dev \
    --to=bug-guix@gnu.org \
    --cc=49613@debbugs.gnu.org \
    --cc=iskarian@mgsn.dev \
    --cc=joshua.r.marshall.1991@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* 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

	https://git.savannah.gnu.org/cgit/guix.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).