adv reqd on SIGCHLD on accept call

Hi,

I have small problem.

In my (concurrent)server programm,
I am handling accept problem from client like this.

sample of server code.
/*******************/

end = 0;
while (! end )
{
sockfd = accept(...)
if(sockfd == -1)
{
if (errno == EINTR) /* this is bcoz of SIGCHLD recvd from child
/
{
continue;
}
else
/
display error and come out*/
{
end = 1;
}
}
else
{
/* continue further .........../
}
}
/
******************/

Is there any way to catch where the error is occuring in the client
process?
(like the line number / or suggest any debugging procedure)

Pl adivce me..

--
Jagannath Desai

use code tags,

end = 0;
while (! end )
{
	sockfd = accept(...)
	if(sockfd == -1)
	{
		if (errno == EINTR) /* this is bcoz of SIGCHLD recvd from child 
		*/
		{
			continue;
		}
		else
		/* display error and come out*/
		{
			end = 1;
		}
	}
else
{
/* continue further ...........*/
}
}

i could not find the corresponding if to the else
the else with continue further...

is the above just a snippet

yes ..
it is a sample part of my server code ..
if child gets killed abruptly then in my server (which is parent process)program, i am checking for EINTR.
but i wanted to check in detail where in my child process, this is happening.

in trace file, am getting error msgs like this..

>>>>>>>>>>>>>
Server : accept error (4)
Server : SIGCHLD received
>>>>>>>>>>>>>>>

.
.
here (4) means EINTER .. right ..

Hi,
finally I got some reasonable trace by using truss command in AIX .
syntax is ..
truss -d -f -p -o jj_trc 5054664

where,
5054664 is the parent pid, on which i did the trace.
jj_trc is the output trace file
-f forces to trace on the childs

I also attached the trace file.
I am triying to find the cause..
Any body simultaneously also can check..

and this is how I handling the signal..

static void trtCHLD(int X)                                                      
{
        int status ;
        pid_t ret_pid;
        fprintf( stderr, "*** SIGNAL SIGCHLD RECEIVED ***\n");
        while ((ret_pid = waitpid((pid_t) -1,(int *) &status ,WNOHANG | WUNTRACED)) > 0);                                                                       

if (ret_pid > 0)
{
  if (WIFEXITED(status)) {
    fprintf(stderr, "Child exited with RC=%d\n", WEXITSTATUS(status));          
  }
  if (WIFSIGNALED(status)) {
    fprintf(stderr, "Child exited via signal %d\n", WTERMSIG(status));          
  }
}
         signal(SIGCHLD,trtCHLD);
         return;                 
 }

and calling this fn in the server..

signal(SIGCHLD,trtCHLD);

before the accept call..

but in the traces files I am not finding any messages getting printed as used in the file.
Is there any changes reqd for the arguements to waitpid function?

Pl any body can have a look at the trace file (generated using truss command) attached in my prev. posting and suggest me on this...

waiting for reply.................

[quote=stevenjagan]
Hi,

I have small problem.

In my (concurrent)server programm,
I am handling accept problem from client like this.

sample of server code.
/*******************/

end = 0;
while (! end )
{
sockfd = accept(...)
if(sockfd == -1)
{
if (errno == EINTR) /* this is bcoz of SIGCHLD recvd from child
/
{
continue;
}
else
/
display error and come out*/
{
end = 1;
}
iavpbmwtvdo