[comp.os.vms] How to be notified if a child process dies prematurely.

wendi@bsu-cs.UUCP (01/17/88)

}
} We are porting our product from a HP9000 running unix to a
} VAX running VMS.  The product is written in c.
} 
} The way the product works is that the frontend (the editor, etc)
} forks off a child process (which does the real work) and the
} two processes talk to each other thru pipes.  All this works fine.
} 
} The question is, how can the parent process tell if the child has
} died?  If something went wrong and the child dies, unless the
} parent knows this, it will hang waiting for input.  In UNIX we use 
} the death of child signal.
} 
} There seem to be several options in VMS.  The first is to
} ask the system if the child process (I have the process id) is 
} still alive using LIB$GETJPI before every read or write.
} I would assume that this would be slow, but I'm not sure.
} 
} The second approach would be to use AST's somehow.  Being new to
} VMS I'm not sure how yet.
} 
} Since this is a fairly common thing to do, I hope someone out there has
} already done it!  I would appreciate any help.  Please remember 
} that I am new to VMS so make your responses fairly detailed.
} 
} Thanks
} 
} Jill Diewald
} Innovative Systems
} 1 Gateway Center Suite 910
} Newton, Ma 02158
} Phone: 617-965-8450
} 
} email: ... /harvard/axiom/insyte/jad

Yes, I agree the AST would seem to be the best way to go about it.  If you are
using Lib$Spawn to create the process, then use the completion-astadr parameter
to specify an AST to be executed when and if the "child" process "dies."  Or if
you are using Sys$CrePrc, then the following procedure might be the best way.
First create a mailbox with Sys$CreMbx.  Second obtain the mailbox's unit 
number by using Sys$GetDVI.  Third set a write attention AST to the mailbox 
with Sys$QIO.  Then call Sys$CrePrc to create the subprocess and make sure that
you specify the mailbox unit number.  Now if the child process dies, an 
accounting message will be written to the mailbox and the AST will fire.
The following manuals would be most helpful:  Run-Time-Library Reference
Manual, System Services Reference Manual, and the I/O User's Guide in the
terminal driver section.


******************************************************************************
*					*				     *
*	Walter H. Dick, III		*	Programming Suggestions      *
*	CS Sophomore			*				     *
*	German Department		*		  by		     *
*	Ball State University		*				     *
*					*	    < Lord Vader >	     *
*					*				     *
******************************************************************************