[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]
Re: popen buffersize limit - doubt
Ramesh wrote (ramesh_tnj@xxxxxxxxx):
> what is the buffer limit for a popen call. suppose u
> want to pipe the ouptput of a command means and the
> output of the command is 350KB means does this will
> work.. then what is the limit of the buffer size of
> the popen function. does it depends on any the system
> runtime availability of resources....
I think that you have a misconcepetion here.... popen creates a pipe, and the
output of the child process is buffered here. The buffer associated with a
pipe is usually very small (size of a VM page in most implementations; 4kb
x86, 8kb alpha).
When the child has filled up the buffer with output it is suspended. Writing
to a full pipe suspends the writer and reading from an empty pipe suspends the
reader. There is no danger of overflowing the buffer, but if you want the
child process to run (no get suspended/blocked) you will have to ensure that
the pipe is never full (keep reading from the pipe). This is important if the
child is vaguely time critical.
Refer to the code posted by a previous poster which illustrates exactly how to
handle pipes/popen. For an exhaustive discussion of the theory and
implementation of pipes refer to "Design and Implementation of the 4.4 BSD
Operating system" Quarterman, or APUE by Rich Stevens (which seems to need no
futher intro to LIP :), or most BSD OS text books.