Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Wg1au-0005eV-Bn for pgsql-hackers@arkaria.postgresql.org; Fri, 02 May 2014 00:44:52 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Wg1at-0003AY-RS for pgsql-hackers@arkaria.postgresql.org; Fri, 02 May 2014 00:44:51 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Wg1as-0003AP-Kw for pgsql-hackers@postgresql.org; Fri, 02 May 2014 00:44:50 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Wg1ap-0000D7-Uj for pgsql-hackers@postgresql.org; Fri, 02 May 2014 00:44:50 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id s420ikfc008750; Thu, 1 May 2014 20:44:46 -0400 From: Tom Lane To: Noah Misch cc: pgsql-hackers@postgresql.org Subject: Re: Obsolete coding in fork_process.c In-reply-to: <20140502000053.GA1191730@tornado.leadboat.com> References: <30040.1398960808@sss.pgh.pa.us> <20140501183231.GA1190179@tornado.leadboat.com> <4013.1398971788@sss.pgh.pa.us> <28165.1398981548@sss.pgh.pa.us> <20140502000053.GA1191730@tornado.leadboat.com> Comments: In-reply-to Noah Misch message dated "Thu, 01 May 2014 20:00:53 -0400" Date: Thu, 01 May 2014 20:44:46 -0400 Message-ID: <8749.1398991486@sss.pgh.pa.us> X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Noah Misch writes: > On Thu, May 01, 2014 at 05:59:08PM -0400, Tom Lane wrote: >> However ... after looking around I notice that fflush(NULL) is already >> being used in parallel pg_dump and pg_upgrade; and at least in the latter >> case I'm afraid to change that because it looks like there are probably >> other stdio output files open in the process. > Do those programs, operating in those modes, read from stdin or some other > long-lived, pipe-backed FILE*? Probably not. However, if that's your criterion, I'd say that I'd much rather assume that the postmaster doesn't have a pipe connected to stdin than that it has no stdio outputs besides stdout/stderr. >> BTW, while working on this I noticed that there are a boatload of places >> where we use system() or popen() without a prior fflush. I suspect most >> of them are safe, or we'd have heard more complaints --- but shouldn't >> we clamp down on that? > You need the fflush() when forking and then using stdio in the child before > any exec(). Have you caught wind of any system() or popen() implementation > having that property? You're only considering one aspect of the problem. Yeah, you might not get duplicated output unless system() prints something before exec(), but we would also like to have causality: that is, whatever we sent to stdout before calling system() should appear there before anything the child process sends to stdout. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers