thanks alot, I can't try your solution cuz im stuck with the dup2 error. Its weird cuz it was working when i didnt check the return value
Replace fileno(stdout) with STDOUT_FILENO and it should work. If not, print the value it actually DOES return. I think it's succeeding and your error checking code is wrong. Have you copied it literally?
thanks alot corona i change the fileno(stdout) to STD_FILENO and its working however i dont know how you manage to get tr to work i did the following change:
This is really interesting however it print everything uppercase at the end, I want to do something interactive where the user type and the system print back uppercase
Im gonna study this code because theres alot of verification. If you check the man for poll pollhup on the event bitmask is ignored (only use for the revents).
Also I dont get why poll for p[1]. Excellent job tough im impress
After a lot of hair pull and experimentation on a real OSX machine I've discovered an insurmountable roadblock to doing this with poll() in OSX. From man poll:
Devices includes terminals, real and virtual.
select() might still support them. You can see code here on how to use select(). linux code, but should be applicable to OSX.
Quote:
This is really interesting however it print everything uppercase at the end, I want to do something interactive where the user type and the system print back uppercase
Well, that's how pipes work. They buffer until they're full. To use them in a nonblocking manner you'll need to set them nonblocking, I think:
...though this behavior may vary from system to system.
Using a seperate process and a pipe to convert lowercase to uppercase is overkill, but I bet you know that and this is just an example...
---------- Post updated at 12:41 AM ---------- Previous update was at 12:31 AM ----------
Quote:
Also I dont get why poll for p[1].
To make sure write(p[1].fd, data, size) doesn't block. Imagine that the child and the parent are writing at the same time, waiting for each other. They'll both wait forever. Instead, we write only when the pipe can hold it.
Hi!
I'm having problems with pipes... I need comunnications with childs processes and parents, but only one child can comunnicate with parent (first child), others childs can't.
A brief of code:
if(pipe(client1r)<0){
perror("pipe");
}
... (1 Reply)
Hi,guys:
I want to use c to implement a pipe. For example:
ps auxwww | grep fred | more
I forked three child processes. Each is responsible for each command, and pipe to next one.
for(i=0;i<2;i++)
pipe(fd)
if(child==1) // child 1
{
close(1)
dup2(fd,1)
close(fd)
}... (3 Replies)
hi i am having issues with extra pipe.
i have a data file and i need to remove the extra pipe in the(example 4th and 7thline) in datafile. there are many other line and filed like this which i need to remove from files. The sample data is below:
270 31|455004|24/03/2010|0001235|72
271... (3 Replies)
Hello !
I want to process a text file in order to extract desired data using sed and grep... Now I am facing a problem piping to grep... nothing happens..
The text consists of blocks of 3 lines that may (or not) contain the Desired data.
the desired data is on each 2... (4 Replies)
Could anyone tell me whats wrong whit this piping? the commands that they execute are correct. the command I am trying is ls|wc. Both processes go to the right if statement.
for(i=0;i<argc;i++){
if(i==0&&argc>1){//first command
if(pipe(pipa1)==-1)
... (2 Replies)
Hi,
Can any one please help me with this. Am struggling hard to get a solution.
I am doing telnet through a C program and getting the stdout file descriptor of the remote machine to pipe.
read() function is getting data, But whenl it receives SOH character ie. ^A ( Start of heading = Console... (2 Replies)
Is there a way to know whether is pipe is opened in read or write mode.I mean is there any signal that is generated when a pipe is opened in read or write mode.
If you have some solution .please let me know ........ (2 Replies)
Basically I am trying to write a short script to report total space used on /u0? file systems. This is what I was trying to do:df -k /u0? | grep -v kbytes | awk '{ printf $2 "+" }' | sed s/.$// | bcBut it returns no output.
This works however: > A=`df -k /u0? |grep -v kbytes | awk '{ printf $2... (2 Replies)
I use read often in scripts to filter the right part into a variable like:
$ print "abc cde efg" | read k l ; print "k=$k, l=$l"
k=, l=
This works on linux and unix versions I work with. On OSX 10.4 this
doesn't work. I found a workaround but would like to know
why the original line... (5 Replies)
I have encountered a strange problem dealing with pipes
and forking. The program basicaly does this:
cat file | tbl | eqn | groff
Now, I have a parent process that forks children
that that exec the stuff that they should. The pipes defined
in the parent are the ones used.
The chain goes... (1 Reply)