| 3 |
|
#include <stdlib.h> |
| 4 |
|
#include <unistd.h> |
| 5 |
|
#include <dirent.h> |
| 6 |
+ |
#include <sys/types.h> |
| 7 |
|
#include "getfile.h" |
| 8 |
|
|
| 9 |
|
|
| 12 |
|
|
| 13 |
|
int myid,numprocs,rank,i; |
| 14 |
|
int nrst_files; |
| 15 |
+ |
int error; |
| 16 |
|
char * dirname = "."; |
| 17 |
|
char *fname; |
| 18 |
|
//char *fname; |
| 19 |
|
extern char **environ; |
| 20 |
|
char *newargv[] ={ |
| 21 |
|
"/bin/echo", |
| 22 |
< |
"File Placeholder", |
| 21 |
< |
"Command options placeholder", |
| 22 |
> |
"Filename", |
| 23 |
|
NULL |
| 24 |
|
}; |
| 25 |
|
MPI_Init(&argc,&argv); |
| 35 |
|
printf("Number of files nrst_files %d\n",nrst_files); |
| 36 |
|
for (i=0;i<nrst_files;i++){ |
| 37 |
|
fname = getfilename(i); |
| 38 |
< |
newargv[1] = fname; |
| 39 |
< |
execve(argv[0],newargv,environ); |
| 38 |
> |
printf("Returned file name on loop %d %s\n",i,fname); |
| 39 |
> |
newargv[1] = fname; |
| 40 |
> |
if (fork() == 0){ |
| 41 |
> |
error = execv(newargv[0],newargv); |
| 42 |
> |
perror("Steve needs a mojito now"); |
| 43 |
> |
exit(1); |
| 44 |
> |
} else { |
| 45 |
> |
wait(&error); |
| 46 |
> |
} |
| 47 |
|
} |
| 40 |
– |
|
| 48 |
|
MPI_Finalize(); |
| 49 |
|
return(0); |
| 50 |
|
} |