Nilesh Rade
Nilesh Rade

Reputation: 43

execve in unix systems

#include<unistd.h>

int main(int argc, char **argv)
{
 int ret;

 ret = execve("/bin/bash", NULL, NULL);

 return 0;

}

i m confuse about why the null values are passsed in execve please help.....

Upvotes: 1

Views: 364

Answers (2)

Cold-Blooded
Cold-Blooded

Reputation: 420

this code opens new shell..... like when you execute any command the shell copies itself and executes the command.

Upvotes: 1

cdhowie
cdhowie

Reputation: 169018

Those parameters correspond to the program's arguments and environment. By passing NULL in for both, the caller is indicating that no arguments should be supplied to the program and no environment variables should be supplied either.

Upvotes: 6

Related Questions