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

Conference turris::digital_unix

Title:DIGITAL UNIX(FORMERLY KNOWN AS DEC OSF/1)
Notice:Welcome to the Digital UNIX Conference
Moderator:SMURF::DENHAM
Created:Thu Mar 16 1995
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:10068
Total number of notes:35879

9092.0. "signal handling" by HYDRA::LNARAYAN () Mon Mar 10 1997 13:43

    Hello
    
    As per their code requirements, a partner is not supposed to wait for 
    the death of child process in their application. So they use SIG_IGN 
    to ignore the death of a child. But this code is not working with 
    Digital UNIX, Works only if the the system V libraies are linked 
    (libsys5.a).
    
    Is there a way to make this work on Digital UNIX without linking the
    sysV libraies. Any ideas? They say the same code ( example attached)
    works with AIX,HP-UX,SunOS. I guess this is due the signal handling
    implementation on Digital UNIX.
    
    Actually the problem is after creating child process, if one exits 
    without waiting for the child to complete, it becomes a defunct. 
    Please note that the partner is using a function to handle this
    circumstance in their application.
    
    Thanks IN Advance
    Lakshminarayan
    
    
    <----------------------- example code ------------------------------>
    
    #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 (;;);
    }
<------------------------- end of the example code ------------------------->
                    
T.RTitleUserPersonal
Name
DateLines
9092.1more infoHYDRA::LNARAYANMon Mar 10 1997 13:4812
    Hello
    
    They are using Digital UNIX V3.2G and/or V4.0
    To reproduce the problem            
    
    1.  Compile the example 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 defuct process whose 
        parent process ID is one of the a.out's PID.
    
9092.2on Digital UNIX no need to bother with child processes if you don't want toVAXCPU::michaudJeff Michaud - ObjectBrokerMon Mar 10 1997 13:5511
	Instead of using signal(3), use sigaction(2) with a sa_flags
	set to:

            SA_NOCLDWAIT
                      If this bit is set and the signal parameter is equal to
                      SIGCHLD, zombie processes are not created by the system
                      when the child process of the calling process exits.
                      If the wait function is subsequently issued by the cal-
                      ling process, it blocks until all of its child
                      processes terminate.  It then returns a value of -1 and
                      errno is set to ECHLD to indicate the error.