OSProcess -OS-X and a unix issue...

John M McIntosh johnmci at smalltalkconsulting.com
Wed Mar 6 21:00:05 UTC 2002


I've uncovered one little issue with os-x and the OSProcess logic 
that needs to be resolved, this hinges on obscure unix knowledge, I'm 
sure there are some obscure unix hackers out there.

When a child process terminates a SIGCHLD is thrown and captured by a 
thread in the Squeak VM that signals a semaphore. This then kicks off 
logic to technically issue a waitpid() however there is a problem...

In the logic it checks to see if the process exists. It invokes


EXPORT(void) primitiveCanReceiveSignals(int anIntegerPid) {

which does this chunk of C code

		result = kill(pidToSignal, 0);
                 result2 = errno; //Grab errno to see what's up


and results is -1, with errno being 3.

#define ESRCH           3               /* No such process */

Note that ps shows:

474 con- Z      0:00.00  (cat)

Note it's in zombie state, and some docs claim.

   * `kill()' returns -1, `errno == ESRCH'

         - either no process exists with the given PID, or security
           enhancements are causing the system to deny its existence. 
(On some systems, the process could be a zombie.)

Needless to say what happens is the Smalltalk code decides that the 
process does not exist and never follows thru with cleanup and 
execution of the waitpid(). WHich then leaves the zombie around, and 
of course prevents any Smalltalk code that is waiting for a external 
process to complete from running...

Note also I tried getpriority() versus kill() that gives similar 
results, and no there is no /proc in this flavor of BSD so I can't 
use that feature to confirm what's up.

So how do you tell if the process id is valid...
-- 
--
===========================================================================
John M. McIntosh <johnmci at smalltalkconsulting.com> 1-800-477-2659
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
===========================================================================



More information about the Squeak-dev mailing list