i am trying to perform the command sh that start a new terminal in Linux from a c program, but i get this error /bin/sh: /bin/sh: cannot execute binary file when i am using execv ()and same result with fork and then execv. but when i tried it system command a succeed , how can i do this command with execv?
work's :
int main (){
system("sh");
return 0;
}
does'nt work :
int main (){
int ret=0;
char *argv[] = {"/bin/bash", "/bin/sh",NULL};
ret=execv(argv[0], argv);
printf("ret: %d \n",ret);
return 0;
}
this code return this error : /bin/sh: /bin/sh: cannot execute binary file