'Why can't I run the execv() syscall?
I can't run execv(), when I build the code it fails.
This is my main.c:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char *argv[])
{
char *args [] = {"Hello", "NESO", "Academy", NULL};
execv("./dotask",args);
printf("this is main.c");
return 0;
}
And this is my dotask.c:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char *argv[]){
printf("we are in dotask.c");
return 0;
}
I want to run the main.c and put char *args into dotask.c with execv() and see printf("we are in dotask.c");, but it fails. Anyone got idea what is the problem with it?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
