From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id mM2zJzfkt2U2VgEAe85BDQ:P1 (envelope-from ) for ; Mon, 29 Jan 2024 18:45:27 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id mM2zJzfkt2U2VgEAe85BDQ (envelope-from ) for ; Mon, 29 Jan 2024 18:45:27 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=wolfsden.cz header.s=mail header.b=vxJrFED1; dkim=fail ("headers rsa verify failed") header.d=wolfsden.cz header.s=mail header.b=vxJrFED1; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=wolfsden.cz (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1706550327; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=iElphaH+StatyTVARuZ3msOqR8dJ3lKIsxgibx0pIg0=; b=psbCE2/Wtbq15JFxV2P/AwxwIqCYNeJe8nXD7sLAsvFMbNyOyOfjrhkmcDsW6iUKyeEcMg 5Pzl2xs0mxOnLqq1dfRWvnRI6SLM2X2IrYsiTNWGTx7aLaHqCvpwGNqygoSw68nP/oJ12H EPgLFYONM7LDSRpQh9SdFyABb9w2e77aK6BKaQQsVkhejPkt8g9tlFYXMnyq/0CciIdgbe Z2sQV3Lc4NQeepyLtPtTqi36zbyVhG5B2tKnyp9EVyPf5bkRKOaC1SSDM3HkQwaQkqXHgr 2F9v3mam/FU6+/INNfcF57u3Ivk5Y2YNiYJqB4kaNYAPOumX1i0hvdDUx721RQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=wolfsden.cz header.s=mail header.b=vxJrFED1; dkim=fail ("headers rsa verify failed") header.d=wolfsden.cz header.s=mail header.b=vxJrFED1; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=wolfsden.cz (policy=none) ARC-Seal: i=1; s=key1; d=yhetil.org; t=1706550327; a=rsa-sha256; cv=none; b=ahm4az7VBfFUKSXaqwvGUqhm6cFKWx1ZjYtiV2xQx/kMEkeJQx0R7qpUppv4yOPkIoqlEo pzu3bwwmtqFKjbIrgahSLvccOsHL6LL05RvQ4OhuAyPusyl3aG7yyLWwtfxkxSrW5SrF5i KK9Bl+0JvQdJWD8iA3afYEzszKYVH0avkMVRbGN1cZCpR3tU98VtEHAZ0kSYqoXf9ik0ru LFgHuspvhF7g0+qm3zJ07S/GjyppVfS5Kvd36ZY2BY5vcIMEtCWzW+sR5H6SH62D99JULQ wZVZnSvf1zreE2ZRTVaATqvHiUBl9hMTTVrc7W4J1cFi1Oz3qJlgtJwxRv00pw== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 70DA36D3FB for ; Mon, 29 Jan 2024 18:45:27 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rUVgm-0000DL-6W; Mon, 29 Jan 2024 12:44:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rUVgk-0000CL-OX for bug-guix@gnu.org; Mon, 29 Jan 2024 12:44:54 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rUVgk-0000aS-FM for bug-guix@gnu.org; Mon, 29 Jan 2024 12:44:54 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rUVgs-0005fr-Ev for bug-guix@gnu.org; Mon, 29 Jan 2024 12:45:02 -0500 X-Loop: help-debbugs@gnu.org Subject: bug#68800: Guix waits for termination of a kernel thread Resent-From: Tomas Volf <~@wolfsden.cz> Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Mon, 29 Jan 2024 17:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68800 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 68800@debbugs.gnu.org Received: via spool by 68800-submit@debbugs.gnu.org id=B68800.170655025421725 (code B ref 68800); Mon, 29 Jan 2024 17:45:02 +0000 Received: (at 68800) by debbugs.gnu.org; 29 Jan 2024 17:44:14 +0000 Received: from localhost ([127.0.0.1]:33376 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rUVg5-0005eK-Tg for submit@debbugs.gnu.org; Mon, 29 Jan 2024 12:44:14 -0500 Received: from wolfsden.cz ([37.205.8.62]:58620) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <~@wolfsden.cz>) id 1rUVg3-0005eA-EZ for 68800@debbugs.gnu.org; Mon, 29 Jan 2024 12:44:12 -0500 Received: by wolfsden.cz (Postfix, from userid 104) id 6E256282AC5; Mon, 29 Jan 2024 17:44:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1706550241; bh=Au24tLn8CRtJ7i3p4JuKQryZLhixJkobSlwHKOGT8I0=; h=Date:From:To:Subject:References:In-Reply-To; b=vxJrFED16o2kacaI0/Rkhhu8fViqSNV6Y0/Ni6nTGUWntum7KObEgMWB9BDMxN9FU nzwS/Ogy9GJNqxWIKX3IGulwKkdlYR2QNTPHS3YZgfJ71etGe+d7NU6hYKeN5cC7KV 4jlyy19Soc7nynyPUuMSCwQ1OzwNpRUybT25oDCdIhkJpZraLIVVZSpW9yuMB2VMum OLNWz+djWDIOriuI6sAdjFz4Ajdy4MT2Kxcj0Qaovdg0e0Nq+9gJY6eX4TtrsWlKs1 mnb878Yeq/mOHJw4kOxuysMXl+sFSUp0Hiqog7L6jg535jBDnIK0Hk4CDSHXIvioRO uPG3tRpQTUYIaRE6ru4566XMDShirKYzAnh+D1Owb+P3fNs5c42iCYEO9a+2xhULtk gRctIe13jIKVACayBURIc0ihlL71VJxbMu5r/zKC6lFdA1tTQu1aEcKIOAg523jWZz kSJt+XkpAN3kAhqHyYIMxU9pZXbe8MPcMAdQlptyYpR2hUFuXej/LGEaFLGLWj1rNf VN5tfN6DRAcu4toxvj1P2gzsqzcB1uEUw3d1kGCdyF2ZJxyJ2GunHIKpy/SOp+WlhT vqd3R+a9Eo4Ww2A2pSs0DrNKDs1/m8r52Yx/1cJVYEXIYrivPJlcJgEbZ9SeXBrSGw E0R9j7p3t1mZyC84N3D1geLI= Received: from localhost (unknown [193.32.127.154]) by wolfsden.cz (Postfix) with ESMTPSA id 09BE528257C for <68800@debbugs.gnu.org>; Mon, 29 Jan 2024 17:44:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1706550241; bh=Au24tLn8CRtJ7i3p4JuKQryZLhixJkobSlwHKOGT8I0=; h=Date:From:To:Subject:References:In-Reply-To; b=vxJrFED16o2kacaI0/Rkhhu8fViqSNV6Y0/Ni6nTGUWntum7KObEgMWB9BDMxN9FU nzwS/Ogy9GJNqxWIKX3IGulwKkdlYR2QNTPHS3YZgfJ71etGe+d7NU6hYKeN5cC7KV 4jlyy19Soc7nynyPUuMSCwQ1OzwNpRUybT25oDCdIhkJpZraLIVVZSpW9yuMB2VMum OLNWz+djWDIOriuI6sAdjFz4Ajdy4MT2Kxcj0Qaovdg0e0Nq+9gJY6eX4TtrsWlKs1 mnb878Yeq/mOHJw4kOxuysMXl+sFSUp0Hiqog7L6jg535jBDnIK0Hk4CDSHXIvioRO uPG3tRpQTUYIaRE6ru4566XMDShirKYzAnh+D1Owb+P3fNs5c42iCYEO9a+2xhULtk gRctIe13jIKVACayBURIc0ihlL71VJxbMu5r/zKC6lFdA1tTQu1aEcKIOAg523jWZz kSJt+XkpAN3kAhqHyYIMxU9pZXbe8MPcMAdQlptyYpR2hUFuXej/LGEaFLGLWj1rNf VN5tfN6DRAcu4toxvj1P2gzsqzcB1uEUw3d1kGCdyF2ZJxyJ2GunHIKpy/SOp+WlhT vqd3R+a9Eo4Ww2A2pSs0DrNKDs1/m8r52Yx/1cJVYEXIYrivPJlcJgEbZ9SeXBrSGw E0R9j7p3t1mZyC84N3D1geLI= Date: Mon, 29 Jan 2024 18:44:00 +0100 From: Tomas Volf <~@wolfsden.cz> Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="SJ55xua6WttYwtt4" Content-Disposition: inline In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: bug-guix-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: 0.74 X-Migadu-Queue-Id: 70DA36D3FB X-Spam-Score: 0.74 X-Migadu-Scanner: mx11.migadu.com X-TUID: e8JwrVgE2YJP --SJ55xua6WttYwtt4 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable > Date: Mon, 29 Jan 2024 17:31:33 +0100 > From: Ludovic Court=E8s > To: guix-devel@gnu.org > Subject: Re: GNU Shepherd 0.10.3 released > > Hi, > > Tomas Volf <~@wolfsden.cz> skribis: > > > Ah, that code indeed returns #f for the pid in question: > > > > scheme@(guix-user)> ((@@ (guix build syscalls) kernel?) 688) > > $1 =3D #f > > > > The stat file: > > > > $ cat /proc/688/stat > > 688 (mt76-tx phy0) S 2 0 0 0 -1 2129984 0 0 0 0 0 0 0 0 -2 0 1 0 96= 4 0 0 18446744073709551615 0 0 0 0 0 0 0 2147483647 0 0 0 0 17 5 1 1 0 0 0 = 0 0 0 0 0 0 0 0 > > > > So the start_code is not zero (I would guess it is -1). I have no idea= what > > that means though. > > What about this method (from shepherd)? > > --8<---------------cut here---------------start------------->8--- > (define (linux-process-flags pid) > "Return the process flags of @var{pid} (or'd @code{PF_} constants), ass= uming > the Linux /proc file system is mounted; raise a @code{system-error} excep= tion > otherwise." > (call-with-input-file (string-append "/proc/" (number->string pid) > "/stat") > (lambda (port) > (define line > (get-string-all port)) > > ;; Parse like systemd's 'is_kernel_thread' function. > (let ((offset (string-index line #\)))) ;offset past 'tcomm' fi= eld > (match (and offset > (string-tokenize (string-drop line (+ offset 1)))) > ((state ppid pgrp sid tty-nr tty-pgrp flags . _) > (or (string->number flags) 0)) > (_ > 0)))))) > > ;; Per-process flag defined in . > (define PF_KTHREAD #x00200000) ;I am a kernel thread > > (define (linux-kernel-thread? pid) > "Return true if @var{pid} is a Linux kernel thread." > (=3D PF_KTHREAD (logand (linux-process-flags pid) PF_KTHREAD))) > --8<---------------cut here---------------end--------------->8--- > > If it works better, we can use that in syscalls.scm as well. Yes, that does seem to work: scheme@(guile-user)> ,use (ice-9 match) scheme@(guile-user)> ,use (ice-9 textual-ports) scheme@(guile-user)> (define (linux-process-flags pid) "Return the process flags of @var{pid} (or'd @code{PF_} constants), a= ssuming the Linux /proc file system is mounted; raise a @code{system-error} exc= eption otherwise." (call-with-input-file (string-append "/proc/" (number->string pid) "/stat") (lambda (port) (define line (get-string-all port)) ;; Parse like systemd's 'is_kernel_thread' function. (let ((offset (string-index line #\)))) ;offset past 'tcomm' = field (match (and offset (string-tokenize (string-drop line (+ offset 1)))) ((state ppid pgrp sid tty-nr tty-pgrp flags . _) (or (string->number flags) 0)) (_ 0)))))) scheme@(guile-user)> ;; Per-process flag defined in . (define PF_KTHREAD #x00200000) ;I am a kernel thread scheme@(guile-user)> (define (linux-kernel-thread? pid) "Return true if @var{pid} is a Linux kernel thread." (=3D PF_KTHREAD (logand (linux-process-flags pid) PF_KTHREAD))) scheme@(guile-user)> (linux-kernel-thread? 685) $5 =3D #t Tomas -- There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors. --SJ55xua6WttYwtt4 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEt4NJs4wUfTYpiGikL7/ufbZ/wakFAmW34+AACgkQL7/ufbZ/ walllQ/+MMP8zMtfyQq/pP6AgKUs+m5cs4OsVhHEhoZjoVPPsewzN8UhMtsnycm0 WelkCJhCmI0JiM/mlNUEaJdgZUWI7jX4V5QbJM/k3DmH05E37UXtqMSShFjkyIJs YdBgNwanxz31A9XhaPutizoWAN3M6V2Tj4wDQlsjI39fkQ0d2N8iuq2Lo7JOs81c 7S/xZqH5gcE1u2wfyw23equFOD88KGpvvdr/xBwM7pBZTP52FY7vYgE9/mLAUyQz B5NrSERCVrbOHZHAorh50JFWKRDHHawK9oekac6+v2jPPTnBUtOg0LPZ+ms34QIe Ln8wxNoUrPZmt47hXj6xw6Q/5sKHW9HQsBoo+4P/gpkGMNJbOAnms1L4vSv1NCq1 UtlvQOQiY3cW5rzU3iyoAuoctVmoPFn2yODAjNgCEs7pp8IxpdJ+pA+p4stVykyf jDN5FV8G0ZFUc7um+gHIx8/vBTinoV/yE6JNF8l0jdWhJhnNO+BaHjGtJRDPZesd ZPGywofauv07y+4sGOoKZ2N4FqvVTn2o0CXpGom74ZMYjpWwFam6hhs2fiygavmI xjTS3M8Gv804vnQyPHmLb+Rbkf5ENRnTyoHCZgirK/PNk1n/Hlnls7VpIJRdfcxX QdDMGCgfClZoZTEd2HVl0TyIF4Gj8igTwmvogKMlsdJM+atXHfM= =cLVC -----END PGP SIGNATURE----- --SJ55xua6WttYwtt4--