![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Question about defunct processes | EMCSANMAN | UNIX for Dummies Questions & Answers | 1 | 02-08-2008 10:03 AM |
| defunct process on HP | shriashishpatil | UNIX for Advanced & Expert Users | 1 | 12-08-2006 06:08 AM |
| defunct process!! | rish2005 | High Level Programming | 5 | 11-30-2005 11:47 AM |
| defunct process due to scohttp on SCO5.0.5 | npn35 | SCO | 0 | 05-26-2005 07:22 AM |
| <DEFUNCT> Processes | cuppjr | UNIX for Dummies Questions & Answers | 4 | 02-26-2001 03:55 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Hi!
I'm newbi in the Unix. I've a C++ Program from where one shell gets executed. Sample C++ code is -- transactionID = 1199; case 1199: //************************************************* // Received the suspend signal. //************************************************* //Call monitoring script, to check proper end of maintstaticloader if (fork() == 0) { execlp("monTx1199.sh", "monTx1199.sh", (char *)0); exit(0); } Name of the C++ program is - MAINRCVR.cpp. And, in the shell i've the following code -- PROCESS=${BINDIR}/DRCVR/MAINTRCVR --------------- Some more process --------------- maintrcvr_pid=`ps -ef | grep -v grep | grep "${PROCESS}" | awk '{print $2}'` kill -s SIGCONT $maintrcvr_pid -But, Even if i kill this process - it is still showing defunct table. We have done test runs of this and it seems to run fine, but all of a sudden after some days of running i see that there are almost 1000 of defunct processes. I've tried -- kill -9 $maintrcvr_pid But, nothing happen. Pls give me some suggestion in this regard. Thanks in advance. Satyaki De. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Forking twice to avoid zombies.
May try the following
if (fork() == 0) //Child of the main code { if (fork()> 0) //Another process is created.(Grandchild) exit(0); //1st child(ret val of fork >0) exits making the Grandchild orphan so it will not be zombie. execlp("monTx1199.sh", "monTx1199.sh", (char *)0); //Above line is executed in the grand child whose status will be retrieved by init. } wait(&status) ; // In the main code where status is an int variable. //or waitpid function to wait for a specific child. //that means we need not wait for the Grandchild to complete , which will run the shell script. Refer Stevens (Advanced Programming in the Unix environment , Process Control Chapter) Last edited by tb75; 04-04-2007 at 04:48 AM. |
|
#3
|
|||
|
|||
|
Hi!
Thanks for your reply. Regards. Satyaki De. Quote:
|
|||
| Google The UNIX and Linux Forums |