I have to create a pipe between 2 process such as the output of the first process
is the input of the second.
In practice I have to do the same thing that the bash does using the follow command:
ls -l|grep mishell
The program works well, but after that grep gives me its output it doesn't come back to
the shell, but stays blocked.
I have tried also to use the mode O_NONBLOCK in the open function, but so the first problem leaves
its place to another. The programm works well, but at the end grep gives me this error:
I think that the problem is that grep attend a particular kind of input to terminate, and ls doesn't
give it this input. I've tried to write a EOF in the fifo after the execution of ls, but there
aren't changes.
If you're going to use a named pipe you would need to open it twice. But you should just use a pipe. Your first process will not create your third process until after the second process finishes. But the second process would be waiting for the third process to read its data. This is a deadlock. You only need two processes anyway. And don't use vfork() anymore, use fork().
Thanx Perderabo, I have solved my problem using as pipe as fifo thanks your suggestion of open
the pipe twice.
I have modifyed your source because your line:
was incorrect.
I hope that you don't judge me presumptuos, but the lack of the ! was harmful for the program. ;P
The prolems are 2.
1) the lack of the ! into the (pid1=fork())
2) the lack of a wait or waitpid function after the else.
The output of your program is correct, but sometimes the first output line is wrote on the shell line, and
always the program waits an enter to terminate.
I have tested your code with a Linux Mandrake 8.2 .
I have created a fifo named pipe in solaris, which writes the content of a file, line by line, into pipe as below:
$ mkfifo namepipe
$ cat books.txt
"how to write unix code"
"how to write oracle code"
$ cat books.txt >> namepipe &
I have a readpipe.sh script which reads the named... (2 Replies)
Hi,
I have a little knowledge about mkfifo, first-in-first-out, a special file, a named pipe and it involves inter-process communication,
as multiple processes can write data into a single file.
Here, I would like to know how this is helpful in executing the below Oracle 'imp' command... (1 Reply)
I'm trying to read a fifo using awk and comming across some problems. I'm writing to the fifo from multiple processes invoked by GNU Parallel:
mkfifo my_fifo
awk '{ a = a + $2 } END { for (i in a) print i, a }' my_fifo | sort -nk1 > sorted_output
grep -v '^@' massive_file | parallel... (3 Replies)
Hi guys.
1. how much is the size of pipe?(i mean the buffer size)
2. is this size different in various UNIX derivations?
3. what happens if we write to a full pipe? does it block until get some free space(the other side receive data) or returns an error?
3. FIFO s are physical files on the... (2 Replies)
Hi
This is a exercise question from Unix network programming vol2.
Why the SIGPIPE signal is generated only for writers when readers disappear.
why not it is generated for readers when writer disappears.
I guess, if the writer didn't get any response like the reader gets EOF,
it will... (4 Replies)
Dear unix gurus,
I have a data file with header information about a subject and also 3 columns of n rows of data on various items he owns. The data file looks something like this:
adam peter
blah blah blah
blah blah blah
car
01 30 200
02 31 400
03 57 121
.. .. ..
.. .. ..
n y... (8 Replies)
Hi,
Program A: uses pipe()
I am able to read the stdout of PROGAM B (stdout got through system() command) into PROGRAM A using:
* child
-> dup2(fd, STDOUT_FILENO);
-> execl("/path/PROGRAM B", "PROGRAM B", NULL);
* parent
-> char line;
-> read(fd, line, 100);
Question:... (2 Replies)
Hi!!
I have a problem reading from a fifo pipe in shell script.
The idea is simple, I have a C program with two pipe files:
An input pipe I use to send commands in shell script to the C program (echo "command" > input.pipe)
An output pipe that I read the result of the command also in... (4 Replies)