# os.isCygwinPty: Fix a bug, replace kernel32 call, and optimize · gitcafe/zig

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

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

Visibility: public

Requested revision: 93b35c69998398e962bff84f3e5006afa122fbde

Requested commit: 93b35c69998398e962bff84f3e5006afa122fbde

Commit: 93b35c69998398e962bff84f3e5006afa122fbde

Tree: b88a6096e8aa0f8602523eadd8d0b2d092458287

Author: Ryan Liptak

Committer: Ryan Liptak

## Message

```
os.isCygwinPty: Fix a bug, replace kernel32 call, and optimize

- Fixes the first few code units of the name being omitted (it was using `@sizeOf(FILE_NAME_INFO)` as the start of the name bytes, but that includes the length of the dummy [1]u16 field and padding; instead the start should be the offset of the dummy [1]u16 field)
- Replaces kernel32.GetFileInformationByHandleEx call with ntdll.NtQueryInformationFile
  + Contributes towards #1840
- Checks that the handle is a named pipe first before querying and checking the name, which is a much faster call than NtQueryInformationFile (this was about a 10x speedup in my probably-not-so-good/take-it-with-a-grain-of-salt benchmarking)

```

## Parents

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

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