# `CliSubprocessCore.EphemeralFiles`
[🔗](https://github.com/nshkrdotcom/cli_subprocess_core/blob/v0.7.0/lib/cli_subprocess_core/ephemeral_files.ex#L1)

Owner-monitored lifecycle for temporary files a provider invocation needs on
disk for the lifetime of a run.

A run may end in six different ways — a normal result, an error, an
interrupt, an explicit close, the death of the process that owns the run, or
a forced teardown — and a temporary file must not survive any of them. An
`after` block covers the first four; it does not run when the owner is killed
untrappably. This process therefore holds the guarantee instead of the owner:
it monitors the owner and removes the owner's files when that monitor fires.

Removal is a single `File.rm/1`, so a forced teardown is bounded by
construction.

# `path`

```elixir
@type path() :: Path.t()
```

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `release`

```elixir
@spec release(path(), GenServer.server()) :: :ok
```

Removes `path` now and stops tracking it. Safe to call more than once.

# `start_link`

```elixir
@spec start_link(keyword()) :: GenServer.on_start()
```

Starts the tracker. The application supervisor starts the singleton; tests
may start isolated instances with `:name`.

# `track`

```elixir
@spec track(path(), pid(), GenServer.server()) ::
  :ok | {:error, :path_already_tracked | :tracker_unavailable}
```

Tracks `path` on behalf of `owner`. When `owner` exits for any reason the
file is removed.

# `tracked?`

```elixir
@spec tracked?(path(), GenServer.server()) :: boolean()
```

Whether `path` is currently tracked. Intended for tests and diagnostics.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
