From jeroen.ooms at stat.ucla.edu  Thu May 14 19:07:30 2015
From: jeroen.ooms at stat.ucla.edu (Jeroen Ooms)
Date: Thu, 14 May 2015 10:07:30 -0700
Subject: [Rd] Reading exit code of pipe()
In-Reply-To: <CAF8bMcZkKrhafAmWuywyPiTXiiJNFwCcXdWyXR3kJmz+mnQBPQ@mail.gmail.com>
References: <CABFfbXv7OzDSt3n9HwkG3Oat0sH3t47LYQZT7ja7QBJQOY9sGw@mail.gmail.com>
	<CAJXgQP3TH2xmyhBCoOow9XzxXzQdvAL0RnLCof8=zd1s1kLXQw@mail.gmail.com>
	<CAF8bMcZkKrhafAmWuywyPiTXiiJNFwCcXdWyXR3kJmz+mnQBPQ@mail.gmail.com>
Message-ID: <CABFfbXuVaXdoW16kw5nUQtpg+=zg+F=B1xwFT6Z9hFjnAR1FZQ@mail.gmail.com>

On Thu, May 14, 2015 at 7:30 AM, William Dunlap <wdunlap at tibco.com> wrote:
> The difference in the return value of close(pipeConnectionObject) seems to depend on whether the pipe connection was opened via the pipe() or open() functions (close() returns NULL) or via something like readLines() or scan() (close() returns status integer).

Hmm interesting. It doesn't help me though; the connection has to be
explicitly opened to support streaming otherwise it keeps running the
command over and over again:

 con <- pipe("ls -ltr /")
 readLines(con, n = 3)
 readLines(con, n = 3)
 readLines(con, n = 3)
 isOpen(con)

Under the hood, R distinguishes "closing" and "destroying" the
connection. The R function close actually means destroy. It seems like
the pipe exit code is only properly returned if the connection was
already closed but not destroyed by the time close() was called.



[Rd] Reading exit code of pipe()
Jeroen Ooms