From debbugs-submit-bounces@debbugs.gnu.org Thu Jan 13 10:37:57 2022 Received: (at 52779) by debbugs.gnu.org; 13 Jan 2022 15:37:57 +0000 Received: from localhost ([127.0.0.1]:34313 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n82An-0005Hp-40 for submit@debbugs.gnu.org; Thu, 13 Jan 2022 10:37:57 -0500 Received: from hera.aquilenet.fr ([185.233.100.1]:59924) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n82Ak-0005HW-2H for 52779@debbugs.gnu.org; Thu, 13 Jan 2022 10:37:55 -0500 Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 8285A2A0; Thu, 13 Jan 2022 16:37:47 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at aquilenet.fr Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LUpf6HjLM18y; Thu, 13 Jan 2022 16:37:46 +0100 (CET) Received: from ribbon (91-160-117-201.subs.proxad.net [91.160.117.201]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 1D4841DC; Thu, 13 Jan 2022 16:37:46 +0100 (CET) From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Maxim Cournoyer Subject: Re: bug#52779: tests/no-home test failure in Shepherd References: <87h7ayys14.fsf@gmail.com> Date: Thu, 13 Jan 2022 16:37:45 +0100 In-Reply-To: <87h7ayys14.fsf@gmail.com> (Maxim Cournoyer's message of "Fri, 24 Dec 2021 09:52:07 -0500") Message-ID: <87ee5b7ik6.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spamd-Bar: / Authentication-Results: hera.aquilenet.fr; none X-Rspamd-Server: hera X-Rspamd-Queue-Id: 8285A2A0 X-Spamd-Result: default: False [-0.10 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TAGGED_RCPT(0.00)[]; MIME_GOOD(-0.10)[multipart/mixed,text/plain,text/x-patch]; RCPT_COUNT_TWO(0.00)[2]; FREEMAIL_TO(0.00)[gmail.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:+,3:+]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; MID_RHS_MATCH_FROM(0.00)[] X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 52779 Cc: 52779@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello, Maxim Cournoyer skribis: > + herd -s t-socket-1651 status root > Started: > + root > + herd -s t-socket-1651 stop root > ++ cat t-pid-1651 > + kill 1896 > + exit 1 > + rm -f t-socket-1651 > + test -f t-pid-1651 > ++ cat t-pid-1651 > + kill 1896 > + rm -f t-pid-1651 > FAIL tests/no-home.sh (exit status: 1) What happens here is that the shepherd process is still alive after =E2=80=98herd stop root=E2=80=99 has completed, contrary to what=E2=80=99s = expected: --8<---------------cut here---------------start------------->8--- $herd stop root if kill `cat "$pid"` then exit 1 fi --8<---------------cut here---------------end--------------->8--- The expectation is that shepherd has terminated by the time =E2=80=98herd s= top root=E2=80=99 exits; I wonder if that=E2=80=99s bogus. =E2=80=98herd stop root=E2=80=99 terminates when shepherd has closed its co= nnection, which normally happens when shepherd exits: --8<---------------cut here---------------start------------->8--- 28003 read(15, "(shepherd-command (version 0) (action stop) (service root) = (arguments ()) (directory \"/data/src/shepherd\"))", 1024) =3D 107 28003 brk(0x1030000) =3D 0x1030000 28003 mmap(NULL, 262144, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_AN= ONYMOUS, -1, 0) =3D 0x7f0072be8000 28003 brk(0x100f000) =3D 0x100f000 28003 getcwd("/data/src/shepherd", 100) =3D 19 28003 chdir("/data/src/shepherd") =3D 0 28003 newfstatat(AT_FDCWD, "/etc/localtime", {st_mode=3DS_IFREG|0444, st_si= ze=3D2962, ...}, 0) =3D 0 28003 write(7, "2022-01-13 16:21:16 Exiting shepherd...\n", 40) =3D 40 28003 chdir("/data/src/shepherd") =3D 0 28003 getuid() =3D 1000 28003 close(13) =3D 0 28003 unlink("test") =3D 0 28003 exit_group(0) =3D ? 28006 <... futex resumed>) =3D ? 28008 <... read resumed> ) =3D ? 28005 <... futex resumed>) =3D ? 28004 <... futex resumed>) =3D ? 28008 +++ exited with 0 +++ 28006 +++ exited with 0 +++ 28005 +++ exited with 0 +++ 28004 +++ exited with 0 +++ 28003 +++ exited with 0 +++ --8<---------------cut here---------------end--------------->8--- Maybe there=E2=80=99s a chance that the shell hasn=E2=80=99t processed the = shepherd=E2=80=99s SIGCHLD when it evaluates the =E2=80=9Cif kill `cat "$pid"`=E2=80=9D condit= ion; in that case, the shepherd process still exists as a zombie. A more robust approach might be to use the shell=E2=80=99s builtin =E2=80= =98wait=E2=80=99, because then I suppose the shell will be forced to process pending SIGCHLDs: --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable diff --git a/tests/no-home.sh b/tests/no-home.sh index 85b6116..5a8c278 100644 --- a/tests/no-home.sh +++ b/tests/no-home.sh @@ -1,5 +1,5 @@ # GNU Shepherd --- Make sure shepherd doesn't fail when $HOME is not writa= ble. -# Copyright =C2=A9 2014, 2016 Ludovic Court=C3=A8s +# Copyright =C2=A9 2014, 2016, 2022 Ludovic Court=C3=A8s # # This file is part of the GNU Shepherd. # @@ -46,7 +46,4 @@ kill -0 `cat "$pid"` $herd status root $herd stop root =20 -if kill `cat "$pid"` -then - exit 1 -fi +wait `cat "$pid"` --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable I can=E2=80=99t get it to fail while waiting for a few minutes of: while make check TESTS=3Dtests/no-home.sh ; do : ; done =E2=80=A6 but I cannot get the original one to fail either. Does it work for you? Ludo=E2=80=99. --=-=-=--