12-15-2007
2,
0
Join Date: Dec 2007
Last Activity: 15 December 2007, 6:54 AM EST
Posts: 2
Thanks Given: 0
Thanked 0 Times in 0 Posts
Doubt regarding Select()
Please provide the solution for the following scenario:
1) There are two process named as ProcessA and ProcessB
2) ProcessA has opend a named pipe in read mode.This has been made as blocking mode.
3) ProcessB opens this pipe and writes in Blocking mode.So wat happens is even if Process A goes down ,ProcessB still waits
that ProcessA will come up since it is in blocking mode.
Solution tried:
1) Made the open system call as non -blocking mode
But here the problem is, when the packet size is more to be sent it keeps on writing and at one time PIPEBUFFER gets filled.
2) So we made the write system as blocking using select
when pipe buffer is full the return value is EAGAIN
code:
retval =write();
if (retval==-1)
{
if(errno==EAGAIN)
{
select()
}
}
so now when pipe buffer is full it is made to blocking,
AGAIN the problem we face is:
For example:
assume : pipe buffer size =100
according to our product, it should write only 10 bytes,assume now the pipe buffer is full
so write() system call will return EAGAIN,it goes to blocking.now even if there is a SINGLE BYTE space ,write will proceed.
kindly provide me some solution -how to fix this issue