---
title: "es_exec_env(_:_:)"
framework: endpointsecurity
role: symbol
role_heading: Function
path: "endpointsecurity/es_exec_env(_:_:)"
---

# es_exec_env(_:_:)

Gets the environment variable at the specified position from a process execution event.

## Declaration

```swift
func es_exec_env(_ event: UnsafePointer<es_event_exec_t>, _ index: UInt32) -> es_string_token_t
```

## Parameters

- `event`: The process execution event.
- `index`: The zero-based index of the argument to return. Attempting to read an out-of-bounds index — where index >= es_exec_arg_count() — results in undefined behavior.

## Return Value

Return Value A string token that contains the environment variable data and its length.

## Discussion

Discussion This function doesn’t allocate memory for the returned token; it points to a string token inside of event. Because you don’t own this memory, don’t try to free it. warning: The returned pointer must not outlive the event parameter passed to the function, because the pointer will likely be invalid after the function returns.

## See Also

### Process Event Helper Functions

- [es_exec_arg(_:_:)](endpointsecurity/es_exec_arg(_:_:).md)
- [es_exec_arg_count(_:)](endpointsecurity/es_exec_arg_count(_:).md)
- [es_exec_env_count(_:)](endpointsecurity/es_exec_env_count(_:).md)
- [es_exec_fd(_:_:)](endpointsecurity/es_exec_fd(_:_:).md)
- [es_exec_fd_count(_:)](endpointsecurity/es_exec_fd_count(_:).md)
- [es_fd_t](endpointsecurity/es_fd_t.md)
