I wrote:
> It remains unclear why you had an intervening shell process when
> I didn't, but perhaps that can be chalked up to use of a different
> shell?
To provide some data on that: popen() is presumably invoking /bin/sh,
which on my box is
$ /bin/sh --version
GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)
$ rpm -qf /bin/sh
bash-4.1.2-48.el6.x86_64
regards, tom lane