Fix: Use PeekNamedPipe to prevent blocking ReadFile on anonymous stdin pipes #25

Merged
gronod merged 1 commits from fix/win32-pipe-peek-named-pipe into development 2026-08-29 14:39:30 +01:00
Owner

Summary

Fixes issue where running interactive measurement utilities (chartread, spotread, dispcal, etc.) as child processes on Windows with piped standard input causes non-blocking stdin polling to deadlock inside ReadFile(), freezing USB endpoint polling for instrument switch triggers.

Fixes #24

Changes

  • spectro/conv.c:
    • In con_char(int wait) under if (stdin_type == FILE_TYPE_PIPE), query available bytes using PeekNamedPipe() before calling ReadFile().
    • When !wait and no bytes are available in the pipe, return immediately with 0 without blocking.
  • doc/ChangesSummary.html:
    • Updated change log.
### Summary Fixes issue where running interactive measurement utilities (`chartread`, `spotread`, `dispcal`, etc.) as child processes on Windows with piped standard input causes non-blocking stdin polling to deadlock inside `ReadFile()`, freezing USB endpoint polling for instrument switch triggers. Fixes #24 ### Changes - **`spectro/conv.c`**: - In `con_char(int wait)` under `if (stdin_type == FILE_TYPE_PIPE)`, query available bytes using `PeekNamedPipe()` before calling `ReadFile()`. - When `!wait` and no bytes are available in the pipe, return immediately with `0` without blocking. - **`doc/ChangesSummary.html`**: - Updated change log.
gronod added 1 commit 2026-08-29 14:39:26 +01:00
gronod merged commit 5b75dd4284 into development 2026-08-29 14:39:30 +01:00
Sign in to join this conversation.