octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: wait_for_file ?? [who/what/where does fclose()?]


From: bpabbott
Subject: Re: wait_for_file ?? [who/what/where does fclose()?]
Date: Fri, 10 Sep 2010 17:31:25 +0000 (GMT)

On 10 Sep, 2010,at 01:21 PM, Michael D Godfrey <address@hidden> wrote:

On 09/10/2010 10:01 AM, Shai Ayal wrote:
This part is written using C io anyway.
What happens in C if you close a file descriptor opened by popen?
Shai
Here is all I know (from man popen):
       The return value from popen() is a normal standard I/O stream in all respects  save
       that  it  must  be  closed  with pclose() rather than fclose(3).  Writing to such a
       stream writes to the standard input of the command; the command’s  standard  output
       is  the  same as that of the process that called popen(), unless this is altered by
       the command itself.  Conversely, reading from a "popened"  stream  reads  the  com-
       mand’s standard output, and the command’s standard input is the same as that of the
       process that called popen().

       Note that output popen() streams are fully buffered by default.
================================================

I would definitely use pclose().

Michael 
 
I've been googling and reading on this, as well. A point I wasn't aware of was the pclose() waits for the process to end before closing the pipe .. but does not pause the execution on the c program. Do I understand that correctly?

Ben

reply via email to

[Prev in Thread] Current Thread [Next in Thread]