[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference hydra::axp-developer

Title:Alpha Developer Support
Notice:[email protected], 800-332-4786
Moderator:HYDRA::SYSTEM
Created:Mon Jun 06 1994
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:3722
Total number of notes:11359

3276.0. "BMC Software" by HYDRA::LNARAYAN () Wed Mar 05 1997 12:11

    Company Name :  BMC Software
    Contact Name :  Murali Somarouthu
    Phone        :  512-340-6227 (512-795-6227)
    Fax          :  
    Email        :  [email protected]
    Date/Time in :   5-MAR-1997 12:07:15
    Entered by   :  L. Narayan
    SPE center   :  MRO

    Category     :  UNIX
    OS Version   :  V3.2G
    System H/W   :  Alpha


    Brief Description of Problem:
    -----------------------------

Murali says that he forks a child process to do certain things ( not explained)
and again forks a grandchild to do somthing else ( not explained), but after
completing the task when exits from the grand child the process hangs or
becoms a defunt process. Needs to avoid this.

I understand evvironment is complex involving socket connections and RDBMS
processess, So requested him to send a sample code or atleast a detailed
writeup on this.

T.RTitleUserPersonal
Name
DateLines
3276.1HYDRA::AXPDEVELOPERAlpha Developer supportThu Mar 06 1997 14:398
    
    Customer sent a test case, but no other information (company name, 
    call tracking number) so mail was sent back to him requesting this
    information.  He just called to confirm he was a member...but 
    unfortunately I cannot find the mail.  I asked him to send it 
    again.
    
    Donna
3276.2HYDRA::AXPDEVELOPERAlpha Developer supportThu Mar 06 1997 15:5187
From:	SMTP%"[email protected]"  6-MAR-1997 14:47:07.02
To:	[email protected]
CC:	
Subj:	1997-3276

Return-Path: [email protected]
Received: by asimov.mro.dec.com (UCX V4.1-12, OpenVMS V6.2 VAX);
	Thu, 6 Mar 1997 14:47:04 -0500
Received: from pobox1.pa.dec.com by fluid.mro.dec.com; (5.65v3.2/1.1.8.2/19Nov96-0448PM)
	id AA08481; Thu, 6 Mar 1997 14:47:11 -0500
Received: by pobox1.pa.dec.com; id AA11957; Thu, 6 Mar 97 11:47:13 -0800
Received: from dresden.bmc.com by mail2.digital.com (5.65 EXP 4/12/95 for V3.2/1.0/WV)
	id AA04404; Thu, 6 Mar 1997 11:41:40 -0800
Received: by dresden.bmc.com
	(1.40.112.4/16.2) id AA027917819; Thu, 6 Mar 1997 13:50:19 -0600
Received: from cherry.bmc.com(172.17.1.25) by dresden.bmc.com via smap (3.2)
	id xma002668; Thu, 6 Mar 97 13:49:57 -0600
Received: from ccmail.bmc.com (banana.bmc.com [172.17.1.201]) by cherry.bmc.com with SMTP (8.7.5/8.7.3) id NAA27033 for <[email protected]>; Thu, 6 Mar 1997 13:41:08 -0600 (CST)
Received: from ccMail by ccmail.bmc.com
  (IMA Internet Exchange 2.1 Enterprise) id 0000429E; Thu, 6 Mar 97 13:40:31 -0600
Mime-Version: 1.0
Date: Thu, 6 Mar 1997 13:42:03 -0600
Message-Id: <[email protected]>
From: [email protected] (Murali Somarouthu)
Subject: 1997-3276
To: [email protected]
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Content-Description: cc:Mail note part

     This is regarding the 'defunc' process being left after the child 
     exits.
     
     I am including a copy of test case here for you to reproduce it on 
     either Digital UNIX OSF1 3.2 G or 4.0.  The problem went way when I 
     linked my binary with -lsys5.  
     
     Here is how to reproduce.
     
     1.  Compile the following code.
     2.  Run the 'a.out'.
     3.  From another terminal window, do 'ps -ef | grep out' and you will 
     see two processes with 'a.out'.
     4.  Now do 'ps -ef | grep defunc' and you will see a defunc process 
     whose parent process ID is one of the a.out's PID.
     
     Now my question is,  even though the signal handling is different in 
     BSD it should not have any problem in cleaning up the ignoring signal. 
     In the following the parent process has a signal handler, but its 
     immediate child ignores the death of child using SIG_IGN.
     
     =====================================================================
     
#include <stdio.h>
#include <sys/signal.h>
void
childhandler(sig)
  int sig;

{
   sigset_t newmask, oldmask;
   int   status;
   if (sig != 20)
      return;
   sigemptyset(&newmask);
   sigaddset(&newmask, 20);
   sigprocmask(1, &newmask, &oldmask);
   while (waitpid(0, &status, 0x1) > 0) ;
   signal(20, childhandler);
   sigprocmask(3, &oldmask, 0L);
}
main()
{
    signal(SIGCLD,childhandler);
    if(fork() == 0)
    {
       signal(SIGCLD,SIG_IGN);
       if(fork() == 0)
       {
       }
       else
         for(;;);
    }
    else
      for (;;);
}

3276.3reply sentHYDRA::LNARAYANMon Mar 10 1997 12:3454
From:	HYDRA::LNARAYAN     "R Lakshminarayan, Software Partner Engg" 10-MAR-1997 12:32:11.15
To:	US4RMC::"[email protected]"
CC:	LNARAYAN
Subj:	your question relating to the defunct processess

Murali

Here is the code that you have sent with two wait system calls 
added to it. This wait() awaits process completion, that is waits
for the child process to stop or terminate. see man wait(2) for
details. If you exit without waiting for the child to complete
then those processes becomes defunct. If you have any questions
please let us know.

Thank YOu
Nari
==================================================================
#include <stdio.h>
#include <sys/signal.h>
void
childhandler(sig)
  int sig;

{
   sigset_t newmask, oldmask;
   int   status;
   if (sig != 20)
      return;
   sigemptyset(&newmask);
   sigaddset(&newmask, 20);
   sigprocmask(1, &newmask, &oldmask);
   while (waitpid(0, &status, 0x1) > 0) ;
   signal(20, childhandler);
   sigprocmask(3, &oldmask, 0L);
}
main()
{
  int pid1,pid2;
    signal(SIGCLD,childhandler);
    if((pid1=fork()) == 0)
    {
       signal(SIGCLD,SIG_IGN);
       if((pid2=fork()) == 0)
       {
	wait(&pid2);
       }
       else
         for(;;);
    }
    else
      for (;;);
	wait(&pid1);
}