From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Redirecting standard output Date: Thu, 21 Apr 2011 17:10:54 +0300 Message-ID: <8362q73dap.fsf@gnu.org> References: <83oc402ky4.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: lo.gmane.org X-Trace: dough.gmane.org 1303394997 4213 80.91.229.12 (21 Apr 2011 14:09:57 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 21 Apr 2011 14:09:57 +0000 (UTC) Cc: emacs-devel@gnu.org To: Lars Magne Ingebrigtsen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Apr 21 16:09:53 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QCuZs-0005lx-8o for ged-emacs-devel@m.gmane.org; Thu, 21 Apr 2011 16:09:52 +0200 Original-Received: from localhost ([::1]:41337 helo=lists2.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QCuZr-0002G8-OR for ged-emacs-devel@m.gmane.org; Thu, 21 Apr 2011 10:09:51 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:37131) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QCuZm-0002G0-RP for emacs-devel@gnu.org; Thu, 21 Apr 2011 10:09:49 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QCuZi-0001dt-LA for emacs-devel@gnu.org; Thu, 21 Apr 2011 10:09:46 -0400 Original-Received: from mtaout22.012.net.il ([80.179.55.172]:35987) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QCuZi-0001da-Ed for emacs-devel@gnu.org; Thu, 21 Apr 2011 10:09:42 -0400 Original-Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0LK000L009Y6PY00@a-mtaout22.012.net.il> for emacs-devel@gnu.org; Thu, 21 Apr 2011 17:09:40 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([77.124.129.240]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0LK000KLAA03S6B0@a-mtaout22.012.net.il>; Thu, 21 Apr 2011 17:09:40 +0300 (IDT) In-reply-to: X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-Received-From: 80.179.55.172 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:138610 Archived-At: > From: Lars Magne Ingebrigtsen > Date: Thu, 21 Apr 2011 15:25:29 +0200 > > However, redirecting STDERR to a buffer seems like it would be quite > complicated, unfortunately. I thought that having STDOUT and STDERR be > handled symmetrically would be a nice feature (for redirecting STDOUT to > one buffer and STDERR to another, for instance), but unless I'm reading > the code wrong (and I very well could be), I don't see an obvious way to > do that. On Posix systems, we use a pipe to read from subprocess's STDOUT. You cannot do the same with STDERR, but you can redirect STDERR to a temporary file, and then read it when the subprocess exits. You can refactor the part of call-process that reads STDOUT and decodes it, and reuse it for STDERR (only reading from a file). Btw, I think the reason why no one implemented that till now is that STDERR normally isn't interesting, unless the subprocess exits with an error code, in which case reading the text from the temporary file to which STDERR was redirected is easy.