Re: Obsolete coding in fork_process.c

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Obsolete coding in fork_process.c
Дата
Msg-id 8749.1398991486@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Obsolete coding in fork_process.c  (Noah Misch <noah@leadboat.com>)
Ответы Re: Obsolete coding in fork_process.c
Список pgsql-hackers
Noah Misch <noah@leadboat.com> 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



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Noah Misch
Дата:
Сообщение: Re: Obsolete coding in fork_process.c
Следующее
От: Noah Misch
Дата:
Сообщение: Re: Obsolete coding in fork_process.c