The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
AWK help reqd Sathy153 Shell Programming and Scripting 17 06-19-2008 12:30 AM
Who sent the process SIGCHLD ? Puntino UNIX for Dummies Questions & Answers 1 06-06-2008 01:43 PM
About SIGCHLD Puntino UNIX for Dummies Questions & Answers 3 05-07-2008 02:10 AM
Help Reqd PradeepRed HP-UX 1 03-15-2007 05:55 PM
Need help with SIGCHLD Unlimited Sky High Level Programming 1 02-21-2005 10:31 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-22-2006
Registered User
 

Join Date: Jul 2006
Posts: 4
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
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 07-22-2006
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,474
use code tags,

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 ...........*/
}
}
i could not find the corresponding if to the else
the else with continue further...

is the above just a snippet
Reply With Quote
  #3 (permalink)  
Old 07-23-2006
Registered User
 

Join Date: Jul 2006
Posts: 4
adv reqd on SIGCHLD on accept call

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.
Reply With Quote
  #4 (permalink)  
Old 07-23-2006
Registered User
 

Join Date: Jul 2006
Posts: 4
Smile adv reqd on SIGCHLD on accept call

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

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

.
.
here (4) means EINTER .. right ..
Reply With Quote
  #5 (permalink)  
Old 07-27-2006
Registered User
 

Join Date: Jul 2006
Posts: 4
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..

Code:
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..

Code:
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.................
Attached Files
File Type: zip jj_trc_new.zip (61.8 KB, 0 views)
Reply With Quote
  #6 (permalink)  
Old 07-28-2006
Registered User
 

Join Date: Jul 2006
Location: canada
Posts: 1
Talking

[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
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 11:37 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0