The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 05-20-2008
swap007 swap007 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 4
problem with socket reading

I am not able to receive the message on socket in the current process when its waiting for its child to exit.

code looks something like below
//in one thread of the current process
//thread 1

===============================================
int numBytes = read(sockid,buf,SIZE); //Now the thread is blocked
================================================


//in another thread
//thread 2

=================================================
if((pid = fork()) == 0) // child process
{
exec(...);
}
else
{
waitpid(pid); //now the process is blocked for the child's exit
}
=================================================
In the above scenario, when child is executing and parent is blocked for child's exit, also when there is some message available on the socket descrtiptor for the first thread to read, I am not able to read that even after child's exit. so could somebody throw more light on the above scenario?

Thanks in advance
Swap007