dev.print + impossible filename -> break (PR#1959)

Prof Brian D Ripley
Wed, 28 Aug 2002 14:53:55 +0100 (BST)

On Wed, 28 Aug 2002 wrote:

> Here's the nub.
> > postscript(file="|llllll")
> > sh: llllll: command not found
> >
> Broken pipe
> and it's related to how popen/pclose are implemented.  The help page
> does say errors are hard to detect, but we can do a bit better than this.

What I tested was checking errno, which the man page says gets set.
But on Linux I find:

popen succeeds, returns a valid file handle and does not set errno.
pclose on that file handle terminates the process.

The last can be avoided by setting a signal handler for SIGPIPE,
although that's not portable across OSes.

Anyone know a portable way to do this?

Brian D. Ripley,        
Professor of Applied Statistics,
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

r-devel mailing list -- Read
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: