Skip to content

in_stdin: support stdin plugin on windows#11821

Open
cosmo0920 wants to merge 2 commits into
masterfrom
cosmo0920-support-stdin-on-windows
Open

in_stdin: support stdin plugin on windows#11821
cosmo0920 wants to merge 2 commits into
masterfrom
cosmo0920-support-stdin-on-windows

Conversation

@cosmo0920
Copy link
Copy Markdown
Contributor

@cosmo0920 cosmo0920 commented May 19, 2026

On Windows, it's a bit of works needed to support in_stdin capability.
In this PR, we're finally enabling a capability to handle stdin on Windows.

Closes #11120.


Enter [N/A] in the box, if an item is not applicable to your change.

Testing
Before we can approve your change; please submit the following in a comment:

  • Example configuration file for the change
cmd> echo {"message":"Hey"} | .\bin\fluent-bit -i stdin -ostdout -v
  • Debug log output from testing the change
Fluent Bit v5.0.6
* Copyright (C) 2015-2026 The Fluent Bit Authors
* Fluent Bit is a CNCF graduated project under the Fluent organization
* https://fluentbit.io

______ _                  _    ______ _ _           _____  _____
|  ___| |                | |   | ___ (_) |         |  ___||  _  |
| |_  | |_   _  ___ _ __ | |_  | |_/ /_| |_  __   _|___ \ | |/' |
|  _| | | | | |/ _ \ '_ \| __| | ___ \ | __| \ \ / /   \ \|  /| |
| |   | | |_| |  __/ | | | |_  | |_/ / | |_   \ V //\__/ /\ |_/ /
\_|   |_|\__,_|\___|_| |_|\__| \____/|_|\__|   \_/ \____(_)\___/


[2026/05/19 16:54:58.246] [ info] Configuration:
[2026/05/19 16:54:58.246] [ info]  flush time     | 1.000000 seconds
[2026/05/19 16:54:58.246] [ info]  grace          | 5 seconds
[2026/05/19 16:54:58.246] [ info]  daemon         | 0
[2026/05/19 16:54:58.246] [ info] ___________
[2026/05/19 16:54:58.246] [ info]  inputs:
[2026/05/19 16:54:58.246] [ info]      stdin
[2026/05/19 16:54:58.246] [ info] ___________
[2026/05/19 16:54:58.246] [ info]  filters:
[2026/05/19 16:54:58.246] [ info] ___________
[2026/05/19 16:54:58.246] [ info]  outputs:
[2026/05/19 16:54:58.246] [ info]      stdout.0
[2026/05/19 16:54:58.246] [ info] ___________
[2026/05/19 16:54:58.246] [ info]  collectors:
[2026/05/19 16:54:58.248] [ info] [fluent bit] version=5.0.6, commit=6474297f3d, pid=40488
[2026/05/19 16:54:58.248] [debug] [engine] maxstdio set: 512
[2026/05/19 16:54:58.248] [debug] [engine] coroutine stack size: 98302 bytes (96.0K)
[2026/05/19 16:54:58.248] [ info] [storage] ver=1.5.4, type=memory, sync=normal, checksum=off, max_chunks_up=128
[2026/05/19 16:54:58.248] [ info] [simd    ] disabled
[2026/05/19 16:54:58.248] [ info] [cmetrics] version=2.1.3
[2026/05/19 16:54:58.248] [ info] [ctraces ] version=0.7.1
[2026/05/19 16:54:58.248] [ info] [input:stdin:stdin.0] initializing
[2026/05/19 16:54:58.248] [ info] [input:stdin:stdin.0] storage_strategy='memory' (memory only)
[2026/05/19 16:54:58.248] [debug] [stdin:stdin.0] created event channels: read=816 write=820
[2026/05/19 16:54:58.248] [debug] [input:stdin:stdin.0] buf_size=16000
[2026/05/19 16:54:58.248] [debug] [stdout:stdout.0] created event channels: read=828 write=832
[2026/05/19 16:54:58.249] [ info] [sp] stream processor started
[2026/05/19 16:54:58.250] [ info] [output:stdout:stdout.0] worker #0 started
[2026/05/19 16:54:58.250] [ info] [engine] Shutdown Grace Period=5, Shutdown Input Grace Period=2
[2026/05/19 16:54:59.255] [debug] [task] created task=0000016C430621D0 id=0 OK
[2026/05/19 16:54:59.255] [debug] [output:stdout:stdout.0] task_id=0 assigned to thread #0
[0] stdin.0: [[1779177298.351077800, {}], {"message"=>"Hey"}]
[2026/05/19 16:54:59.256] [debug] [out flush] cb_destroy coro_id=0
[2026/05/19 16:54:59.256] [debug] [task] destroy task=0000016C430621D0 (task_id=0)
[2026/05/19 16:55:02] [engine] caught signal (SIGINT)
[2026/05/19 16:55:02.280] [ warn] [engine] service will shutdown in max 5 seconds
[2026/05/19 16:55:02.280] [ info] [engine] pausing all inputs..
[2026/05/19 16:55:03.292] [ info] [engine] service has stopped (0 pending tasks)
[2026/05/19 16:55:03.292] [ info] [output:stdout:stdout.0] thread worker #0 stopping...
[2026/05/19 16:55:03.292] [ info] [output:stdout:stdout.0] thread worker #0 stopped
  • Attached Valgrind output that shows no leaks or memory corruption was found

If this is a change to packaging of containers or native binaries then please confirm it works for all targets.

  • Run local packaging test showing all targets (including any new ones) build.
  • Set ok-package-test label to test for all targets (requires maintainer to do).

Documentation

  • Documentation required for this feature

Backporting

  • Backport to latest stable release.

Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.

Summary by CodeRabbit

  • Bug Fixes
    • Improved Windows compatibility for the stdin input plugin by enabling it as a default input option on Windows systems. Enhanced platform-specific handling to increase reliability and stability when reading from standard input sources, ensuring consistent and predictable behavior across different types of input streams on Windows.

Review Change Stack

cosmo0920 added 2 commits May 19, 2026 16:57
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 19, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b256bbae-0555-4db2-ac00-32e5d3a6439f

📥 Commits

Reviewing files that changed from the base of the PR and between 6474297 and 183f5e4.

📒 Files selected for processing (3)
  • cmake/windows-setup.cmake
  • plugins/in_stdin/in_stdin.c
  • plugins/in_stdin/in_stdin.h

📝 Walkthrough

Walkthrough

The PR enables the stdin input plugin on Windows by adding Windows-specific I/O handling. It detects stdin type (pipe vs. console), implements platform-aware availability checking via Win32 APIs, switches to time-based collection polling on Windows, and conditionally manages file descriptors and cleanup paths.

Changes

Windows stdin input plugin support

Layer / File(s) Summary
Data structures and Windows constants
plugins/in_stdin/in_stdin.h
Header adds Windows includes, FLB_STDIN_WIN32_COLLECT_NSEC polling constant, and stdin_handle/stdin_type struct fields to track Windows stdin state.
Windows I/O implementation and collection integration
plugins/in_stdin/in_stdin.c
Introduces stdin_win32_available() (using PeekNamedPipe() and _kbhit()) and stdin_read() wrapper; updates collection path to use the wrapper and handle zero-byte returns on Windows pipes without treating as EOF.
Initialization and Windows stdin handle acquisition
plugins/in_stdin/in_stdin.c
Initialize ctx->fd = -1, then on Windows acquire stdin handle via GetStdHandle()/GetFileType() before duplicating with _dup(_fileno(stdin)) (non-Windows uses dup(STDIN_FILENO)).
Collector registration and polling strategy
plugins/in_stdin/in_stdin.c
Windows registers time-based polling via FLB_STDIN_WIN32_COLLECT_NSEC; non-Windows retains event-based collector watching ctx->fd.
Error handling and resource cleanup
plugins/in_stdin/in_stdin.c
Close ctx->fd using _close() on Windows or close() elsewhere in both init error paths and normal shutdown, guarded by ctx->fd >= 0.
Build configuration
cmake/windows-setup.cmake
Enable FLB_IN_STDIN input plugin when FLB_WINDOWS_DEFAULTS CMake option is set.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

  • Windows support for stdin plugin #11120 — The PR directly implements Windows-specific stdin support (CMake enablement plus new Windows I/O helpers, handle management, and polling logic) to address the requested Windows stdin plugin feature.

Suggested labels

docs-required

Suggested reviewers

  • edsiper

Poem

🐰 On Windows, stdin now speaks clear,
With PeekNamedPipe and polling near,
Console and pipes both find their way,
Time-based collection saves the day!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'in_stdin: support stdin plugin on windows' clearly and concisely describes the main change: enabling stdin input plugin support on the Windows platform.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cosmo0920-support-stdin-on-windows

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cosmo0920 cosmo0920 added this to the Fluent Bit v5.1 milestone May 19, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 183f5e4156

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread plugins/in_stdin/in_stdin.c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows support for stdin plugin

1 participant