Fix for run-process causing STk to exit in 2.1.7.

From: Harvey J. Stein <hjstein_at_MATH.HUJI.AC.IL>
Date: Sun, 8 Oct 1995 13:31:56 +0200

I found a fix for the problem of STk exiting when a child process
(created by run-process) exits.

As far as I know, things are supposed to work as follows. The
run-process function runs processes as a child process of the STk
process. When a child process exits, the parent is sent the SIGCHLD
signal. STk installs a handler of SIGCHLD, so that when the child
process exits, STk can clean up the data structures associated with
the child.

The problem is that if a signal occurs during a system call, the
system call can be interrupted, and will return an error. Typically,
STk is waiting in a call to getc when the child exits, so the getc
call gets interrupted. Unfortunately, STk was interpreting this as
receiving an end-of-file from getc, and thus was exiting.

This all applies to STk 2.1.7 and 2.2.0 (I think). Checking the code
for the new Beta version 3.0, it seems that this might have been fixed
by wrapping all system calls in SYSTEM(), which presumably turns off
interrupts before making the system call, but I'm not sure.

An alternative easy fix for the SIGCHLD in version 2.1.7 (for those of
you that upgrading), is a minor modification to Src/process.c,
changing:

    sigact.sa_flags = SA_NOCLDSTOP; /* Ignore SIGCHLD generated by SIGSTOP */

to:

    /* Ignore SIGCHLD generated by SIGSTOP, and restart system calls... */
    sigact.sa_flags = SA_NOCLDSTOP|SA_RESTART;

Note that this only works on systems that have sigaction, and it only
deals with SIGCHLD. On the other hand, it will automatically deal
with *all* system calls, and in this sense is more robust than
wrapping all system calls with code to retry the system call if it's
interrupted, or to turn off interrupts, or whatever (because a
programmer might miss afew, but the system won't).

Good luck,

Dr. Harvey J. Stein
Berger Financial Research
hjstein_at_math.huji.ac.il
Received on Sun Oct 08 1995 - 12:32:44 CET

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST