Added option PND_EXEC_OPTION_BLOCK to require libpnd to hang until child process completes.
* (shell, bin, whatever.) pndrun specifies the full path to the pnd_run sh script, which should be
* found using searchpaths and locates.. see locatetest.c for a sample
* NOTE: Use pnd_locate function to locate the pnd_run, for example
- * NOTE: clock speed will be set prior to invoking the script, and set back on exit
+ * NOTE: if specified, clock speed will be set prior to invoking the script, and set back on exit
* NOTE: No values can be except clockspeed; a 0 clockspeed means 'leave alone'. Set startdoir to "." instead of NULL.
* fork() is implied; calling this function does not kill this process :)
* NOTE: PAss in the full path to the awesomeapp.pnd or to the directory containing PXML.xml (not the PXML.xml itself.)
+ * Options is a set of boolean flags, derived from the #define's below; OR them together.
+ * option-block, when set, suggests the launch should wait until the invoked application exits (disregarding why app exits)
+ * example: options = PND_EXEC_OPTION_BLOCK | PND_EXEC_OPTION_2;
*/
-unsigned char pnd_apps_exec ( char *pndrun, char *fullpath, char *unique_id, char *rel_exec, char *rel_startdir, unsigned int clockspeed );
+#define PND_EXEC_OPTION_NIL 0
+#define PND_EXEC_OPTION_BLOCK 1
+#define PND_EXEC_OPTION_FUTURE 2
+#define PND_EXEC_OPTION_FUTURE2 4
+
+unsigned char pnd_apps_exec ( char *pndrun, char *fullpath, char *unique_id,
+ char *rel_exec, char *rel_startdir,
+ unsigned int clockspeed, unsigned int options );
#ifdef __cplusplus
} /* "C" */
#include <string.h> /* for memset */
#include <unistd.h> /* for fork/exec */
+#include <sys/types.h> /* for wait */
+#include <sys/wait.h> /* for wait */
+
#include "pnd_container.h"
#include "pnd_pxml.h"
#include "pnd_apps.h"
-unsigned char pnd_apps_exec ( char *pndrun, char *fullpath, char *unique_id, char *rel_exec, char *rel_startdir, unsigned int clockspeed ) {
+unsigned char pnd_apps_exec ( char *pndrun, char *fullpath, char *unique_id,
+ char *rel_exec, char *rel_startdir,
+ unsigned int clockspeed, unsigned int options )
+{
char *argv [ 20 ];
int f;
- printf ( "Entering pnd_apps_exec\n" );
+ //printf ( "Entering pnd_apps_exec\n" );
+
#if 0
printf ( " runscript: %s\n", pndrun );
printf ( " path: %s\n", fullpath );
execv ( pndrun, argv );
}
- printf ( "Exiting pnd_apps_exec\n" );
+ // by definition, either error occurred or we are the original application.
+
+ // do we wish to wait until the child process completes? (we don't
+ // care if it crashed, was killed, was suspended, whatever.)
+ if ( options & PND_EXEC_OPTION_BLOCK ) {
+ int status = 0;
+ //waitpid ( f, &status. 0 /* no options */ );
+ wait ( &status );
+ }
+
+ // printf ( "Exiting pnd_apps_exec\n" );
return ( 1 );
}
sprintf ( fullpath, "%s/%s", d -> object_path, d -> object_filename );
}
printf ( "Trying to exec '%s'\n", fullpath );
- pnd_apps_exec ( pndrun, fullpath, d -> unique_id, d -> exec, d -> startdir, atoi ( d -> clockspeed ) );
+ pnd_apps_exec ( pndrun, fullpath, d -> unique_id, d -> exec, d -> startdir, atoi ( d -> clockspeed ), PND_EXEC_OPTION_BLOCK );
}
}