From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39549) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fpFbZ-00030C-QO for guix-patches@gnu.org; Mon, 13 Aug 2018 12:22:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fpFbW-0002Ba-JB for guix-patches@gnu.org; Mon, 13 Aug 2018 12:22:05 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:44877) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fpFbW-0002BA-Eb for guix-patches@gnu.org; Mon, 13 Aug 2018 12:22:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fpFbW-0007xA-84 for guix-patches@gnu.org; Mon, 13 Aug 2018 12:22:02 -0400 Subject: [bug#32358] Add pcscd service Resent-Message-ID: References: <87a7q2lqc6.fsf@garuda.local.i-did-not-set--mail-host-address--so-tickle-me> <87zhxu7lr9.fsf@gmail.com> <87sh3jkyqg.fsf@gmail.com> <878t5b6u1r.fsf@lassieur.org> <87ftziybse.fsf@gmail.com> From: =?UTF-8?Q?Cl=C3=A9ment?= Lassieur In-reply-to: <87ftziybse.fsf@gmail.com> Date: Mon, 13 Aug 2018 18:21:33 +0200 Message-ID: <87600e6xv6.fsf@lassieur.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Chris Marusich Cc: 32358@debbugs.gnu.org Chris Marusich writes: > Thank you for mentioning this. You make a good point. I'm not yet > familiar with all the different ways Shepherd manages its herd of > processes. For example, I know Shepherd looks for the #:pid-file when > first starting the process to determine whether it started up > successfully. When using MAKE-FORKEXEC-CONSTRUCTOR, yes. And it makes sense only for blocking processes, because they are 'dumb', they don't return information about whether they have succesfully started or not. However, 'pcscd' is smart, it does return '1' if it failed to start, and '0' if it started successfully. So, all the logic (the pid check and everything) is done within 'pcscd' itself, no need for the Shepherd to do it. (start (pid-of smart-nonblocking-process)) =3D=3D (start (make-forkexec-con= structor dumb-blocking-process)) > However, I don't know if Shepherd uses that PID file for anything else > while managing the process later on. No, it doesn't use the #:PID-FILE argument for anything else. However, it does use the return value of the start procedure as a PID file to automatically respawn the service if it's an integer. So you just need to return (call-with-input-file pid-file read) instead of #t if you want automatic respawning, as in https://git.savannah.gnu.org/cgit/guix.git/commit/?id=3Dfdbca05d78d091bfc07= 5e54c9fb90125262eadf0. > In any case, the procedure make-forkexec-constructor seems to hide a lot > of the nitty gritty details (e.g., closing file descriptors), so I think > it would be better to use it instead of invoking pcscd on our own if we > don't have to. All this stuff is done by 'pcscd' when run without '-f', using MAKE-FORKEXEC-CONSTRUCTOR doesn't help in any way. Moreover, we do lose the 'syslog' feature if we use it. > Perhaps we can do the following: > > * Run pcscd in the foreground (with -f). > * Use make-forkexec-constructor. > * Tell Shepherd about the PID file via the #:pid-file option to > make-forkexec-constructor. > * Redirect pcscd's stdout/stderr to /var/log/pcscd via the #:log-file > option to make-forkexec-constructor. > > That way, we can still use the convenient make-forkexec-constructor > procedure, Shepherd will still be able to manage the process, and people > will be able to find the logs more easily. > What do you think? I think it's better to use syslog ;-) By the way, 'syslogd' should be added as a requirement I think. >> Also, the systemd unit files I've seen use the '--auto-exit' and >> '--hotplug' options. Do you know if they make sense for us? [...] > Maybe in the future we can think of helpful ways to use these options, > but for now I think it's OK to omit them. Ok! Cl=C3=A9ment