[Openais] instantiation cleanup

Steven Dake sdake at redhat.com
Mon Aug 7 16:05:35 PDT 2006


Hans,

The reason there is a separate openais-instantiate is that I could not
get waitpid to work the way I wanted from within AMF itself.  Another
reason is that I could not determine how to execute fork from within a
shell script, and then return the error code (waitpid) of the forked
process.

The basic nature I believe is that clc_cli_script should execute the
application, and then return an error code when the application is done.
The issue arises when the application doesn't return immediately as
would be expected of most applications that do not disconnect from their
TTY on startup (ie: daemonize).  We also have to work properly with
applications that do daemonize after their initialization and no error
could occur.  This problem is a bit tricky.

Finally the forked process child must record its cleanup PID so that the
cleanup clc_cli_script command will kill the child if a component
restart is desired.

If we can address these issues, then it is safe to remove openais-
instantiate.  I'd recommend not removing it until a full replacement is
in place, since it would break the ability for AMF to operate at all.

Regards
-steve

On Mon, 2006-08-07 at 08:45 +0200, Hans Feldt wrote:
> Steven, I don't understand the need for openais-instantiate.c and would 
> like to remove that file. Is that OK with you?
> 
> It seems to add some timed wait for an early exit of a component but 
> later we will have time supervised CLC execution but from within AMF 
> that takes care of that.
> 
> Regards,
> Hans
> 
> Steven Dake wrote:
> > The cleanup clc command for AMF was being run, but it didn't properly
> > kill off the application because openais-instantiate didn't create the
> > correct file.  Patch attached to fix.
> > 
> > Regards
> > -steve
> > 
> > 
> > ------------------------------------------------------------------------
> > 
> > Index: exec/openais-instantiate.c
> > ===================================================================
> > --- exec/openais-instantiate.c	(revision 1177)
> > +++ exec/openais-instantiate.c	(working copy)
> > @@ -39,6 +39,9 @@
> >  #include <semaphore.h>
> >  #include <errno.h>
> >  #include <string.h>
> > +#include <stdlib.h>
> > +#include <sys/stat.h>
> > +#include <fcntl.h>
> >  
> >  struct timespec sleeptime = {
> >  	.tv_sec = 0,
> > @@ -59,7 +62,14 @@
> >  	pid_t res;
> >  	int status;
> >  	int i;
> > +	char *env_value;
> > +	char cleanup_filename[1024];
> > +	char cleanup_pid[64];
> > +	int fd;
> >  
> > +	env_value = getenv ("SA_AMF_COMPONENT_NAME");
> > +	sprintf (cleanup_filename, "/var/run/openais_cleanup_%s", env_value);
> > +
> >  	pid = fork();
> >  	if (pid == -1) {
> >  		fprintf (stderr, "openais-instantiate: could not fork process %s\n",
> > @@ -92,7 +102,13 @@
> >  		return (0);
> >  	} else {
> >  
> > -		xprintf ("childs pid %d\n", getpid());
> > +		sprintf (cleanup_pid, "%d", getpid());
> > +		xprintf ("childs pid %s\n", cleanup_pid);
> > +
> > +		fd = open (cleanup_filename, O_CREAT|O_WRONLY, 0777);
> > +		res = write (fd, cleanup_pid, strlen (cleanup_pid));
> > +		close (fd);
> > +
> >  		/*
> >  		 * child process
> >  		 */
> > 
> > 
> > ------------------------------------------------------------------------
> > 
> > _______________________________________________
> > Openais mailing list
> > Openais at lists.osdl.org
> > https://lists.osdl.org/mailman/listinfo/openais
> 




More information about the Openais mailing list