I want to launch another program from my C program and return the shell and PID. Here is what I've tried.
struct app_names{
const char *run_args[TOTAL_NUM_APP] = {
" inp.in",
" 3000 reference.dat 0 0 100_100_130_ldc.of",
}
const char *run_exe[TOTAL_NUM_APP] = {
"./mcf",
"./lbm"
}
};
struct app_names SPEC_RUN;
pid_t child;
child = fork();
char RUN_EXE[2048] = "";
strcat(RUN_EXE, SPEC_RUN.run_exe[0]);
strcat(RUN_EXE, EXE_SUFIX);
strcat(RUN_EXE, SPEC_RUN.run_args[0]);
if(!child)
execlp(SPEC_RUN.run_exe[0], SPEC_RUN.run_exe[0], SPEC_RUN.run_args[0], (char *)0);
What exactly am I missing here? why doens't the program launch?
strerror(errno)value. Also, is your struct C valid code?execlpparms you pass and what the value oferrnois when it fails. It would have taken less time than it took to type this question.