From unknown Sat Jun 21 10:29:19 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#8303 <8303@debbugs.gnu.org> To: bug#8303 <8303@debbugs.gnu.org> Subject: Status: Emacs daemon initialization should not ignore I/O errors Reply-To: bug#8303 <8303@debbugs.gnu.org> Date: Sat, 21 Jun 2025 17:29:19 +0000 retitle 8303 Emacs daemon initialization should not ignore I/O errors reassign 8303 emacs submitter 8303 Paul Eggert severity 8303 minor thanks From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 20 19:34:36 2011 Received: (at submit) by debbugs.gnu.org; 20 Mar 2011 23:34:36 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q1S8q-0002YB-KV for submit@debbugs.gnu.org; Sun, 20 Mar 2011 19:34:36 -0400 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q1S8p-0002Xz-9g for submit@debbugs.gnu.org; Sun, 20 Mar 2011 19:34:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q1S8i-00079Z-HL for submit@debbugs.gnu.org; Sun, 20 Mar 2011 19:34:30 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_RP_MATCHES_RCVD autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([199.232.76.165]:33353) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q1S8i-00079N-D6 for submit@debbugs.gnu.org; Sun, 20 Mar 2011 19:34:28 -0400 Received: from [140.186.70.92] (port=55795 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q1S8h-0001lI-8k for bug-gnu-emacs@gnu.org; Sun, 20 Mar 2011 19:34:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q1S8g-00078g-8d for bug-gnu-emacs@gnu.org; Sun, 20 Mar 2011 19:34:27 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]:47790) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q1S8f-00078R-SP for bug-gnu-emacs@gnu.org; Sun, 20 Mar 2011 19:34:26 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id C9C9839E80DC for ; Sun, 20 Mar 2011 16:34:23 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tUwZrn5WDjjV for ; Sun, 20 Mar 2011 16:34:23 -0700 (PDT) Received: from [192.168.1.10] (pool-71-189-109-235.lsanca.fios.verizon.net [71.189.109.235]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 3DC1B39E80DA for ; Sun, 20 Mar 2011 16:34:23 -0700 (PDT) Message-ID: <4D868EFE.1000806@cs.ucla.edu> Date: Sun, 20 Mar 2011 16:34:22 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.14) Gecko/20110223 Thunderbird/3.1.8 MIME-Version: 1.0 To: bug-gnu-emacs@gnu.org Subject: Emacs daemon initialization should not ignore I/O errors Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 199.232.76.165 X-Spam-Score: -4.7 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.7 (----) Severity: minor daemon-initialized currently ignores I/O errors when setting up the daemon, but it should report them, on the off chance that system resources are low so that (for example) one cannot open /dev/null or dup a file descriptor. I plan to install the following patch in the trunk, to address this. 2011-03-20 Paul Eggert * emacs.c (Fdaemon_initialized): Do not ignore I/O errors. --- src/emacs.c 2011-03-17 16:32:03 +0000 +++ src/emacs.c 2011-03-20 21:03:44 +0000 @@ -2312,6 +2312,7 @@ (void) { int nfd; + int err = 0; if (!IS_DAEMON) error ("This function can only be called if emacs is run as a daemon"); @@ -2324,10 +2325,11 @@ /* Get rid of stdin, stdout and stderr. */ nfd = open ("/dev/null", O_RDWR); - dup2 (nfd, 0); - dup2 (nfd, 1); - dup2 (nfd, 2); - close (nfd); + err |= nfd < 0; + err |= dup2 (nfd, 0) < 0; + err |= dup2 (nfd, 1) < 0; + err |= dup2 (nfd, 2) < 0; + err |= close (nfd) != 0; /* Closing the pipe will notify the parent that it can exit. FIXME: In case some other process inherited the pipe, closing it here @@ -2336,10 +2338,13 @@ Instead, we should probably close the pipe in start-process and call-process to make sure the pipe is never inherited by subprocesses. */ - write (daemon_pipe[1], "\n", 1); - close (daemon_pipe[1]); + err |= write (daemon_pipe[1], "\n", 1) < 0; + err |= close (daemon_pipe[1]) != 0; /* Set it to an invalid value so we know we've already run this function. */ daemon_pipe[1] = -1; + + if (err) + error ("I/O error during daemon initialization"); return Qt; } From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 23 18:07:01 2011 Received: (at 8303-done) by debbugs.gnu.org; 23 Mar 2011 22:07:03 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q2WCi-0007ux-G6 for submit@debbugs.gnu.org; Wed, 23 Mar 2011 18:07:01 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q2WCb-0007uA-KO; Wed, 23 Mar 2011 18:06:54 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 7955339E80F5; Wed, 23 Mar 2011 15:06:47 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id DCQ03AM5OnEs; Wed, 23 Mar 2011 15:06:47 -0700 (PDT) Received: from [131.179.64.200] (Penguin.CS.UCLA.EDU [131.179.64.200]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 2047839E80B1; Wed, 23 Mar 2011 15:06:47 -0700 (PDT) Message-ID: <4D8A6EF6.6010006@cs.ucla.edu> Date: Wed, 23 Mar 2011 15:06:46 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.15) Gecko/20110307 Fedora/3.1.9-0.39.b3pre.fc14 Thunderbird/3.1.9 MIME-Version: 1.0 To: 8310-done@debbugs.gnu.org, 8318-done@debbugs.gnu.org, 8306-done@debbugs.gnu.org, 8303-done@debbugs.gnu.org, 8277-done@debbugs.gnu.org, 8298-done@debbugs.gnu.org, 8290-done@debbugs.gnu.org, 8278-done@debbugs.gnu.org Subject: fix merged to trunk Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Spam-Score: -3.3 (---) X-Debbugs-Envelope-To: 8303-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.2 (---) I committed a fix to the trunk for this, as part of a recent merge (bzr 103721). From unknown Sat Jun 21 10:29:19 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 21 Apr 2011 11:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator