# exec Family: execve

```c
/* Exec/execve.c */
#include <stdio.h>
#include <unistd.h>
int main(int argc,char *argv[]){ 
    char *env[] = {"LS_COLORS=fi=04;33;44",NULL}; 
    char *arg[] = {"ls","-l","--color",NULL}; 
    printf("Using *execve* to exec ls -l\n");  
    execve("/bin/ls",arg,env); 
    printf("Program Terminated\n");
    return 0;
}
```

`execve()` uses *filename*, *argument array* and *provided ENV* to execute the program.

```c
execve("/bin/ls",arg,env);
```

It only takes a filename to invoke the program, and it is searched in paths specified in `$PATH` in sequence.

The arguments are listed in an array of `char*` and passed to the function.

The new sets of environment variables are declared in an array of `char*` and passed to the program in the function. They can be used to change the behavior of the new program, for example, `ls` in this example.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://eric-lo.gitbook.io/lab4-process/process-execution/exec-family-execve.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
