Re: popen, file descriptors, etc.

Brendan Burns <bburns-bjBJFzlPIWP2fBVCVOL8/[email protected]>
Newsgroups gmane.lisp.mcl.general,gmane.lisp.cclan.general
Message-ID <[email protected]>
Check "man popen" under OS X one of the bugs listed is:

The popen argument always calls sh(1), never calls csh(1)

which would lead you to believe that popen maybe ought to call another 
shell at some other time...  (although it probably always calls sh)

--brendan

On Wednesday, January 21, 2004, at 08:51 AM, james anderson wrote:

>
> On Wednesday, Jan 21, 2004, at 10:13 Europe/Berlin, Gary Byers wrote:
>
>>>> ...
>> popen uses the shell to execute the command, so if tar's verbose
>> output is indeed going to /dev/console in this case you can ask
>> the shell to redirect it for you:
>
> it was indeed there.
>
>>
>> "tar -C SOME-DIRECTORY -zxvf SOME-FILE 2>&1"
>>
>> where the "2>&1" is so obvious and intuitive that it's barely
>> worth mentioning that it causes the process to run with file
>> descriptor 2 set to a duplicate of fd 1.
>
> evidently the description in the sh man page
>        [n1]>&n2
>               Duplicate standard output (or n) from n2.
>
> was even more obvious to me, as i did try this, but got it backwards.
>
> ok.
> so now the next question: is popen specified to run sh in all unix 
> versions?
>
> ...
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.