Re: psql client quits after 1st command

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Cc: Vincenzo Romano <vincenzo(dot)romano(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: psql client quits after 1st command
Date: 2007-03-02 18:43:40
Message-ID: 15299.1172861020@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Martijn van Oosterhout <kleptog(at)svana(dot)org> writes:
> I don't think you can acheive the effect you want with a FIFO.

I think Doug had it right: the trick is to have some process holding the
FIFO open for write throughout the procedure, so that the reader (psql)
doesn't see an EOF. This doesn't necessarily have to be the same
process(es) that're actually putting data into the FIFO.

Per the read(2) man page:

When attempting to read from an empty pipe or FIFO:

o If no process has the pipe open for writing, read() will
return 0 to indicate end-of-file.

o If some process has the pipe open for writing and O_NONBLOCK
is set, read() will return -1 and set errnoto EAGAIN.

o If some process has the pipe open for writing and O_NONBLOCK
is clear, read() will block until some data is written or the
pipe is closed by all processes that had the pipe open for
writing.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joshua D. Drake 2007-03-02 18:52:14 WITH/RECURSIVE plans
Previous Message Tom Lane 2007-03-02 18:18:17 Re: Re : pg_dump, serial