2 #include <stdio.h> /* for FILE etc */
3 #include <stdlib.h> /* for malloc */
4 #include <string.h> /* for memset */
5 #include <unistd.h> /* for fork/exec */
7 #include <sys/types.h> /* for wait */
8 #include <sys/wait.h> /* for wait */
10 #include "pnd_container.h"
14 unsigned char pnd_apps_exec ( char *pndrun, char *fullpath, char *unique_id,
15 char *rel_exec, char *rel_startdir,
16 unsigned int clockspeed, unsigned int options )
21 //printf ( "Entering pnd_apps_exec\n" );
40 printf ( " runscript: %s\n", pndrun );
41 printf ( " path: %s\n", fullpath );
42 printf ( " id: %s\n", unique_id );
43 printf ( " exec: %s\n", rel_exec );
44 printf ( " cwd: %s\n", rel_startdir );
45 printf ( " clock: %u\n", clockspeed );
48 memset ( argv, '\0', sizeof(char*) * 20 );
51 argv [ f++ ] = pndrun;
53 argv [ f++ ] = fullpath;
55 argv [ f++ ] = rel_exec;
58 argv [ f++ ] = rel_startdir;
61 argv [ f++ ] = unique_id;
63 // skip -a (arguments) for now
65 if ( options & PND_EXEC_OPTION_NOUNION ) {
66 argv [ f++ ] = "-n"; // no union for now
69 if ( options & PND_EXEC_OPTION_NOX11 ) {
70 argv [ f++ ] = "-x"; // no union for now
74 argv [ f++ ] = NULL; // for execv
79 for ( i = 0; i < f; i++ ) {
80 printf ( "exec's argv %u [ %s ]\n", i, argv [ i ] );
86 if ( ( f = fork() ) < 0 ) {
92 execv ( pndrun, argv );
95 // by definition, either error occurred or we are the original application.
97 // do we wish to wait until the child process completes? (we don't
98 // care if it crashed, was killed, was suspended, whatever.)
99 if ( options & PND_EXEC_OPTION_BLOCK ) {
101 //waitpid ( f, &status. 0 /* no options */ );
105 // printf ( "Exiting pnd_apps_exec\n" );