From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Matthew Leach Newsgroups: gmane.emacs.devel Subject: Re: [PATCH v3] Add systemd socket launching support Date: Thu, 31 Mar 2016 14:31:46 +0100 Message-ID: <871t6qkc3h.fsf@mattleach.net> References: <874mbn7kmn.fsf@mattleach.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1459431151 26684 80.91.229.3 (31 Mar 2016 13:32:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 31 Mar 2016 13:32:31 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Mar 31 15:32:23 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1alchv-00079S-St for ged-emacs-devel@m.gmane.org; Thu, 31 Mar 2016 15:32:20 +0200 Original-Received: from localhost ([::1]:60475 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1alchv-0001p5-2E for ged-emacs-devel@m.gmane.org; Thu, 31 Mar 2016 09:32:19 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37012) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1alchV-0001jU-9J for emacs-devel@gnu.org; Thu, 31 Mar 2016 09:31:57 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1alchQ-0006Lx-BS for emacs-devel@gnu.org; Thu, 31 Mar 2016 09:31:53 -0400 Original-Received: from mx0.mattleach.net ([176.58.118.143]:41942) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1alchQ-0006Lt-6F for emacs-devel@gnu.org; Thu, 31 Mar 2016 09:31:48 -0400 Original-Received: by mx0.mattleach.net (Postfix, from userid 99) id 75A646222F; Thu, 31 Mar 2016 14:31:47 +0100 (BST) Original-Received: from spline.mattleach.net (host81-159-23-200.range81-159.btcentralplus.com [81.159.23.200]) by mx0.mattleach.net (Postfix) with ESMTPSA id 6D1096222B; Thu, 31 Mar 2016 14:31:45 +0100 (BST) In-Reply-To: (Stefan Monnier's message of "Thu, 31 Mar 2016 08:55:36 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 176.58.118.143 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:202501 Archived-At: Hi Stefan, Stefan Monnier writes: >> +#include > [..] >> +#ifdef HAVE_SYSTEMD >> + /* Read the number of sockets passed through by systemd. */ >> + systemd_socket = sd_listen_fds(1); > > AFAICT, this is the core of the dependency to systemd. Yes, that's correct. There is also a call to `sd_is_socket' just below this line. > Could you explain to us, how the socket information is actually > passed? Is it passed via an env-var? I believe so, I'm not a systemd expert, though. Looking at the man page for the sd_listen_fds: Internally, sd_listen_fds() checks whether the $LISTEN_PID environment variable equals the daemon PID. If not, it returns immediately. Otherwise, it parses the number passed in the $LISTEN_FDS environment variable, then sets the FD_CLOEXEC flag for the parsed number of file descriptors starting from SD_LISTEN_FDS_START. Finally, it returns the parsed number. HTH, -- Matt