[comp.os.vms] Completion Status in LIB$SPAWN

R022DB3L@VB.CC.CMU.EDU (Mithrandir) (09/30/87)

I'm encountering strange returns when using the completion status field of
the RTL routine LIB$SPAWN to check the exit status of an image I'm spawning.

Basically, I use LIB$SPAWN to invoke EMACS (the standard text editor here)
in order to edit a temporary file.  I check the return code for the spawn
call to see if that worked, and if it checks out, I then check the return
information in the completion status field to see if the EMACS image 
encountered any problems.  From reading my friendly orange manuals, I was
lead to believe that the completion status code is simply the standard VMS
exit code for the image (or whatever you are doing in the spawn).

In general this causes no problems, and I get a nice return of SS$_NORMAL
from both lib$spawn and the status field.  However, if I pause EMACS (a
function to leave the emacs process in place and return to the parent
process), the spawn succeeds, but the condition status code returns a
value of 2146620316 (7FF2D39C hex).  This seems much higher than any normal
return codes I've seen in the past, and as it's even should indicate an
error, although none occured.

My question is not so much EMACS specific as it is just on the general
use of the completion field - can I assume it to be a standard VMS return
code?  Where would I be getting such an extremely large number on an
apparently successful call?  And if anyone is familiar with EMACS (this
being the Unipress version), has anyone else ever encountered this?

Right now I'm eliminating the completion status check because it is incorrectly
identifying an error where none exists - but I don't want to leave it out in
the final version, because then all I'd be checking is the spawn result, and
not the result of the actual operation being performed in the sub-process.

Any comments, suggestions, etc.. would be much appreciated.


-- David Bolen				Arpanet:  R022DB3L@VB.CC.CMU.EDU
   Carnegie-Mellon University		Bitnet :  R022DB3L@CMCCVB
   Pittsburgh, PA  15213

jimp@cognos.uucp (Jim Patterson) (10/15/87)

In article <8710011304.AA13458@ucbvax.Berkeley.EDU> R022DB3L@VB.CC.CMU.EDU (Mithrandir) writes:
>I'm encountering strange returns when using the completion status field of
>the RTL routine LIB$SPAWN to check the exit status of an image I'm spawning.
>  if I pause EMACS (a
>function to leave the emacs process in place and return to the parent
>process), the spawn succeeds, but the condition status code returns a
>value of 2146620316 (7FF2D39C hex).

I suspect that the completion status has not been set at all. It isn't
set until the process you've spawned actually dies, and from what you
have said, you have left it paused but still existing. You can confirm
this by first setting the condition status to a known value like 0.

If you need to know whether a process is still running, another useful
facility of lib$spawn (if I recall it correctly) is the completion ast
routine. This will be invoked when the process terminates, at which 
point you can do whatever you need to to clean up. It sounds as if
what you really want to do is check that your emacs process actually
starts up correctly (doesn't die because of image not found, etc.).
This may require some more sophisticated synchronization than what you're
describing. Due to process startup time, it almost certainly won't be
the case that the completion status will be set immediately after the
lib$spawn call. You will at the very least have to wait for some
period of time before it will have a valid value.
-- 
Jim Patterson                              Cognos Incorporated
UUCP:decvax!utzoo!dciem!nrcaer!cognos!jimp P.O. BOX 9707    
PHONE:(613)738-1440                        3755 Riverside Drive
                                           Ottawa, Ont  K1G 3Z4