Technical article 110690

Process started by cron fails to remove exiting children from process table.

OpenServer 5.0.5

Written · Last revised

Problem

The signal handling function for a process that forks children and is started by cron(C) does not get called on a system where Support Level Supplement (SLS) OSS497C, the Core OS Supplement for OpenServer 5.0.5, has been installed.

For example if the following program is run as a cron job, a zombie process (one with a "defunct" entry in the process table) is created and the expected output from the printf in function "pippo" does not get mailed to root:

#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <sys/wait.h>
pid_t pippo_pid;
void pippo(int sig)
{
        int i;
        pid_t waited_for;
printf("got signal %d\n", sig);
waited_for = wait(&i);

printf("pippo's pid was (%d), waited (%d) bye\n", pippo_pid, waited_for); exit(0); }

void main(void)
{
        switch ( pippo_pid = fork() )
        {
        case -1:
                fprintf(stderr, "fork failed!\n");
                exit(1);
case 0:
        freopen("/dev/null", "a", stdout);
        freopen("/dev/null", "a", stderr);
        execl("/bin/ls", "ls", "/", NULL);
        fprintf(stderr, "exec failed!\n");
        exit(1);
default:
        if ( (signal(SIGCLD, pippo)) == SIG_ERR )
        {
                fprintf(stderr, "SIG_ERR\n");
                exit(1);
        }
                sleep(1000);
                if ( errno == EINTR )
                {
                        fprintf(stderr, "GOT SIGNAL\n");
                }
        }
}

Cause

/etc/cron was modified in OSS497C to fix the following problem:

The cron utility would get "stuck" waiting for long jobs to complete, blocking its ability to accept and run new "at now" jobs promptly.

Solution

This problem is fixed in SCO OpenServer Release 5.0.6.

If the above limitation does not affect the system in question the previous version of cron can be linked back to /etc/cron.

Use the following command to locate the previous version of cron:

find /opt/K/SCO/Unix/5.0.5Eb/.softmgmt/patchBackup -name cron -exec ls -l {} \;

This is an example of what the above command outputs if the Release Supplement 505A was the last patch installed before OSS497C (to double check that this is the version of cron that was backed up by the OSS497C installation, the date stamp on this file should correspond to the time at which OSS497C was installed):

---x------   1 bin      bin        56440 Dec 16 20:05
./rs505a.Unix505.1.0a/etc/cron

So the complete path for the previous version of cron is:

/opt/K/SCO/Unix/5.0.5Eb/.softmgmt/patchBackup/rs505a.Unix505.1.0a/etc/cron

Use the following commands to link the previous version of cron to /etc/cron and set permissions (substituting the path obtained from running the above command on your own system, if different from the one in this example):

ln -f -s \
/opt/K/SCO/Unix/5.0.5Eb/.softmgmt/patchBackup/rs505a.Unix505.1.0a/etc/cron \
/etc/cron
chmod u+x \
/opt/K/SCO/Unix/5.0.5Eb/.softmgmt/patchBackup/rs505a.Unix505.1.0a/etc/cron

Note that if the Fix Discrepancies option is taken while running the Software Manager Verify System utility, the above commands may then need to be rerun.

NOTE:     The signal(S) routine was used here to reproduce a customer
          problem. However, please note the following advice from the
          signal(S) man page:

The signal routine is not considered to be completely reliable for some applications. Therefore, it is strongly recommended that the sigaction routine(S), which supersedes the signal routine, be used in all new applications instead.

See also

cron(C), signal(S), sigaction(S)

ta110105, "What is SLS OSS497C, the Core OS Supplement for SCO OpenServer Release 5.0.5?"

From the Xinuos technical article database, record 110690. Reproduced with permission. The original is at www.sco.com/ta/110690, which is reachable but blocked from search engines.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.