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
zombie processes and hung process termination ukndoit Shell Programming and Scripting 2 03-13-2008 10:53 PM
NOTICE:u79n:Abnormal interrupt! int_status=FC67C0D0 fadil Filesystems, Disks and Memory 1 04-10-2007 07:53 AM
Abnormal Inact Memory jipznet1981 Filesystems, Disks and Memory 0 06-22-2006 12:01 PM
Inter Process File Handling Problem saurabhjain HP-UX 4 05-12-2005 08:49 AM
Abnormal Termination errors bialsibub UNIX for Dummies Questions & Answers 2 11-14-2001 07:21 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-10-2006
Registered User
 

Join Date: Sep 2005
Posts: 20
handling abnormal process termination

hi

i m writin a program in which i keep track of all the child processes the program has generated and if a child process has an abnormal termination i need to do certain task related to that child process.
for handlin child process i used waitpid:

temp_cpid=waitpid(-1,&stat,WUNTRACED);

during normal termination temp_cpid return the pid of the terminated child process but in case of abnormal termination it returns -1 so hoe to determine the pid of the abnormally terminated process?

ny help will b appreciated

thanx
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 01-10-2006
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,868
The macro
Code:
 WIFSIGNALED(stat)
will return the signal the child process handled.
Reply With Quote
  #3 (permalink)  
Old 01-12-2006
Registered User
 

Join Date: Jan 2006
Posts: 5
Try This

Hi,
Thanks for the ftp C reply,
May be you could try this to track all the child process

#include<signal.h>


static void handle_child_process(int sig)
{
/* this will print all the child proccess status code termination values */
int stat;
printf("%d",wait(&stat));
}

int main()
{
struct sigaction child_signal;
memset(&chld_signal, 0, sizeof(struct sigaction));

child_signal.sa_handler = &handle_child_process;
sigaction(SIGCHLD, &child_signal, 0);

/*
your
code
here
wahtever
it is
*/

exit(EXIT_SUCCESS);
}
/*
do something like this
*/
Reply With Quote
  #4 (permalink)  
Old 01-13-2006
linuxpenguin's Avatar
Registered User
 

Join Date: May 2002
Location: India
Posts: 295
Hi Mridula,
basically SIGCHLD is the signal that is generated as a result of termination of the child process. so you should bt looking to handle that

i got this nice info after some google.
http://www.wlug.org.nz/SIGCHLD

not sure if it applies to your ux version. but good info tho
__________________
War doesnt determine who is right, it determines who is left
Reply With Quote
  #5 (permalink)  
Old 01-16-2006
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,586
Quote:
Originally Posted by cjediknight
static void handle_child_process(int sig)
{
/* this will print all the child proccess status code termination values */
int stat;
printf("%d",wait(&stat));
}
i am afraid that the above statement would print
only the PIDS of the child process that are terminated and not the exit status of the child process.

Code:
int stat;
printf("%d",wait(&stat));
printf("%d",stat);
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 09:04 AM.


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

Content Relevant URLs by vBSEO 3.2.0