> For the complete documentation index, see [llms.txt](https://davidjosearaujo.gitbook.io/notes-miect/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://davidjosearaujo.gitbook.io/notes-miect/sistemas-de-operacao/processes-in-unix-linux/execution-of-a-c-c++-program.md).

# Execution of a C/C++ program

<figure><img src="https://933056030-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmDWmJ4LyRblScRPGY3di%2Fuploads%2FcKFe0adLP7Ns8B9U8oIS%2Fa.png?alt=media&amp;token=0a667d42-d631-4c3b-b903-079deb9dede4" alt=""><figcaption></figcaption></figure>

## *atexit*

The **atexit** function allows to register a function to be called at the program’s normal terminatio&#x6E;*.*

They are called in reverse order relative to their registe&#x72;*.*

<figure><img src="https://933056030-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmDWmJ4LyRblScRPGY3di%2Fuploads%2FSLHfUgGep9e2pvzCstp7%2Fa.png?alt=media&amp;token=0d179d3d-71fa-4bcb-8e35-e7b9a29ad506" alt=""><figcaption></figcaption></figure>

## Command line arguments and environment variables

**argv** is an array of strings.

**argv\[0]** is the program reference.

**env** is an array of strings, each representing a variable, in the form **name-value** pair.

**getenv** returns the value of a variable name.

<figure><img src="https://933056030-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmDWmJ4LyRblScRPGY3di%2Fuploads%2FJn5uxvTBV4jODlssx0Dv%2F2022-10-01_09-30.png?alt=media&amp;token=498b3fab-347a-4274-97e3-f4c3f5e20a03" alt=""><figcaption></figcaption></figure>

## Address space of a Unix process

<figure><img src="https://933056030-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmDWmJ4LyRblScRPGY3di%2Fuploads%2FMhZlawfROxK9h9b6eSuV%2Fa.png?alt=media&amp;token=96654945-72c5-4faa-8781-53562ad05bda" alt=""><figcaption></figcaption></figure>

<figure><img src="https://933056030-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmDWmJ4LyRblScRPGY3di%2Fuploads%2FlAVD4B6p6XF1JVFp8Pjk%2Fa.png?alt=media&amp;token=f3d86d6e-e8be-4406-bbd2-e3753db6a9d4" alt=""><figcaption></figcaption></figure>

<figure><img src="https://933056030-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmDWmJ4LyRblScRPGY3di%2Fuploads%2FPdyZM7UcCwnlInqBKwsj%2Fa.png?alt=media&amp;token=fbf7c986-4238-4a6b-baff-b6df547bde92" alt=""><figcaption></figcaption></figure>
