# child_process: Use security attributes while creating handle\. · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/194ed308259e49af3f4725659e22ccd7457404e0)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 194ed308259e49af3f4725659e22ccd7457404e0

Requested commit: 194ed308259e49af3f4725659e22ccd7457404e0

Commit: 194ed308259e49af3f4725659e22ccd7457404e0

Tree: da51480a82b6158902496d032115990001520e8e

Author: xEgoist

Committer: Andrew Kelley

## Message

```
child_process: Use security attributes while creating handle.

As suggested by @matu3ba, it can be better to use Security Attributes
directly while creating the handle instead of creating the handle then
setting the handle to inherit. Doing so can prevent potentially leaking
to other parallel spawned processes which would inherit the opened `\Device\Null`
handle.

This change also allows windows.OpenFile to handle when bInheritHandle
is set.

Note that we are using the same `saAttr`, but since it's taken as a
pointer to a const in all calls, it's never mutated, and OpenFile never alters it.

This also saves 1 kernel call for setting the handle to inherit.

```

## Parents

- [41bf816fa6dd6fde0264db885c2f00757aba74b0](https://git.cafe/gitcafe/zig/commit/41bf816fa6dd6fde0264db885c2f00757aba74b0?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/194ed308259e49af3f4725659e22ccd7457404e0?format=markdown)
