Reputation: 862
I'm trying to create a simple program that will allow to execute basic shell commands. Problem is execve just hangs everytime.
Heres the code:
char* arglist[]={"ls","-l",NULL};
char* env[]={NULL};
int status;
while (1)
{
if (fork() != 0)
{
waitpid(-1, &status, 0);
}
else
{
execve(arglist[0],arglist,env);
}
}
return 0;
}
Upvotes: 0
Views: 1224
Reputation: 121407
The first arguments should be a full path to the binary you execute:
char* arglist[]={"/bin/ls", "-l", NULL};
Upvotes: 3