473,474 Members | 1,614 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

conveyor non-stop

Hi, folks

I wish to make the conveyor, but i can't receive the answer
before I shall close a pipe.

For example:

int
main ()
{
int rpipe [2];
int wpipe [2];

::pipe (rpipe);
::pipe (wpipe);

pid_t _pid;

enum { RD, WR };

if (0 == (_pid=::fork()))
{
::close (rpipe [WR]);
::dup2 (rpipe [RD], STDIN_FILENO); // read rpipe through stdin
::close (rpipe [RD]);

::close (wpipe [RD]);
::dup2 (wpipe [WR], STDOUT_FILENO); // write stdout to wpipe
::close (wpipe [WR]);

::execl ("/usr/bin/tr", "tr", "A-Z", "a-z", 0);
cout << ::strerror (errno) << endl;
return errno;

} else {
::close (rpipe [RD]);
::close (wpipe [WR]);

std::string line;
while ( std::getline (cin, line)) {

::write ( rpipe [WR], line.c_str(), line.size () );
::write ( rpipe [WR], "\n" , sizeof("\n") );
///::close ( rpipe [WR]);

/// With close() I read; without close() I blocked
/// But close() destroy my cool conveyor!
/// How to me to avoid it?

char buf [1024];
int n = ::read ( wpipe [RD], buf, 1024 );
buf [n] = '\0';

cout << buf << endl;
}
}
}

--
www.andr.mobi
Dec 28 '07 #1
3 1546
Andrew Wingorodov wrote, On 28/12/07 12:58:
Hi, folks

I wish to make the conveyor, but i can't receive the answer
before I shall close a pipe.

For example:

int
main ()
{
int rpipe [2];
int wpipe [2];

::pipe (rpipe);
::pipe (wpipe);
<snip>

This is definitely not C. It could be C++, but that is a different
language. It could also be an extension to C++. I suggest probably
either comp.unix.programmer or comp.lang.c++ would be better places to
ask depending on whether my guess that is a POSIX extension is correct
or whether you are using standard C++. However, before posting in one of
those groups do what you failed to do here, i.e. actually check what the
group is about.
--
Flash Gordon
Dec 28 '07 #2
Flash Gordon <sp**@flash-gordon.me.ukwrote:
>
This is definitely not C. It could be C++, but that is a different
I speak C - I mean UNIX
I speak UNIX - I mean C

(c)
those groups do what you failed to do here, i.e. actually check what the
group is about.
i so sorry
never mind

--
www.andr.mobi
Dec 28 '07 #3
Andrew Wingorodov wrote:
>
I wish to make the conveyor, but i can't receive the answer
before I shall close a pipe.

For example:

int main () {
int rpipe [2];
int wpipe [2];

::pipe (rpipe);
::pipe (wpipe);
This is not C. I suspect you want comp.lang.c++.

--
Merry Christmas, Happy Hanukah, Happy New Year
Joyeux Noel, Bonne Annee, Frohe Weihnachten
Chuck F (cbfalconer at maineline dot net)
<http://cbfalconer.home.att.net>

--
Posted via a free Usenet account from http://www.teranews.com

Dec 28 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: klaus triendl | last post by:
hi, recently i discovered a memory leak in our code; after some investigation i could reduce it to the following problem: return objects of functions are handled as temporary objects, hence...
3
by: Mario | last post by:
Hello, I couldn't find a solution to the following problem (tried google and dejanews), maybe I'm using the wrong keywords? Is there a way to open a file (a linux fifo pipe actually) in...
25
by: Yves Glodt | last post by:
Hello, if I do this: for row in sqlsth: ________pkcolumns.append(row.strip()) ________etc without a prior:
32
by: Adrian Herscu | last post by:
Hi all, In which circumstances it is appropriate to declare methods as non-virtual? Thanx, Adrian.
8
by: Bern McCarty | last post by:
Is it at all possible to leverage mixed-mode assemblies from AppDomains other than the default AppDomain? Is there any means at all of doing this? Mixed-mode is incredibly convenient, but if I...
14
by: Patrick Kowalzick | last post by:
Dear all, I have an existing piece of code with a struct with some PODs. struct A { int x; int y; };
11
by: ypjofficial | last post by:
Hello All, So far I have been reading that in case of a polymorphic class ( having at least one virtual function in it), the virtual function call get resolved at run time and during that the...
2
by: Ian825 | last post by:
I need help writing a function for a program that is based upon the various operations of a matrix and I keep getting a "non-aggregate type" error. My guess is that I need to dereference my...
399
by: =?UTF-8?B?Ik1hcnRpbiB2LiBMw7Z3aXMi?= | last post by:
PEP 1 specifies that PEP authors need to collect feedback from the community. As the author of PEP 3131, I'd like to encourage comments to the PEP included below, either here (comp.lang.python), or...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.