yes it is supposedly easier to use a temporary file, but is it possible
to use popen() for the given instance ?
how can the required read and write achieved using popen(), when as you
mentioned popen() allows only one at a time ?
-- Satish
On Sun, 2008-11-16 at 18:56 +0000, Richard Tobin wrote:
to use popen() for the given instance ?
how can the required read and write achieved using popen(), when as you
mentioned popen() allows only one at a time ?
-- Satish
On Sun, 2008-11-16 at 18:56 +0000, Richard Tobin wrote:
In article <525be7b5-f6d1-4826-9668-cd0909e65446@1g 2000prd.googleg roups.com>,
Snaggy <l.cioria@gmail .comwrote:
>
>
Reading and writing to another program through pipes is, in general, a
recipe for deadlock. In the case of "wc" this wouldn't be a problem,
but if you were using something like "tr" it would. To make it work
requires some kind of asynchronous (or select()ed) i/o, multiple
threads, or arbitrary buffering in the operating system. Consequently
the unix popen() call only provides for you to either read or write,
not both.
>
For this simple case, your solution of using a temporary file is
probably the easiest, requiring little unix-specific knowledge.
>
-- Richard
Snaggy <l.cioria@gmail .comwrote:
>
Or any other standar unix program..
I want to pass something to a pipe for wc (to count words) and read
the result into a variable..
For now I put an intermediate result into a file and then open the
file and read it..
I want to pass something to a pipe for wc (to count words) and read
the result into a variable..
For now I put an intermediate result into a file and then open the
file and read it..
Reading and writing to another program through pipes is, in general, a
recipe for deadlock. In the case of "wc" this wouldn't be a problem,
but if you were using something like "tr" it would. To make it work
requires some kind of asynchronous (or select()ed) i/o, multiple
threads, or arbitrary buffering in the operating system. Consequently
the unix popen() call only provides for you to either read or write,
not both.
>
For this simple case, your solution of using a temporary file is
probably the easiest, requiring little unix-specific knowledge.
>
-- Richard
Comment