Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bin: windows: Restore Ctrl-C behavior on windows #7986

Merged
merged 2 commits into from
Oct 2, 2023

Conversation

cosmo0920
Copy link
Contributor

@cosmo0920 cosmo0920 commented Sep 28, 2023

After supporting fleet management on Windows,
Ctrl-C events won't be caught up.
This commit re-enables for the behavior.
Windows' ctrl event handlers stolen signals which are overlapped ones. So, we need to handle Ctrl-C events on the newly added event handler for Windows.

In Windows, SIGINT and SIGBREAK are valid ctrl events on their terminal. This is why we only need to handle CTRL_C_EVENT and CTRL_BREAK_EVENT events on console handler.

Closes #7985


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
PS> bin/fluent-bit -i random -o stdout -v
  • Debug log output from testing the change
Fluent Bit v2.1.10
* Copyright (C) 2015-2022 The Fluent Bit Authors
* Fluent Bit is a CNCF sub-project under the umbrella of Fluentd
* https://fluentbit.io

[2023/09/28 16:19:48] [ info] Configuration:
[2023/09/28 16:19:48] [ info]  flush time     | 1.000000 seconds
[2023/09/28 16:19:48] [ info]  grace          | 5 seconds
[2023/09/28 16:19:48] [ info]  daemon         | 0
[2023/09/28 16:19:48] [ info] ___________
[2023/09/28 16:19:48] [ info]  inputs:
[2023/09/28 16:19:48] [ info]      random
[2023/09/28 16:19:48] [ info] ___________
[2023/09/28 16:19:48] [ info]  filters:
[2023/09/28 16:19:48] [ info] ___________
[2023/09/28 16:19:48] [ info]  outputs:
[2023/09/28 16:19:48] [ info]      stdout.0
[2023/09/28 16:19:48] [ info] ___________
[2023/09/28 16:19:48] [ info]  collectors:
[2023/09/28 16:19:48] [ info] [fluent bit] version=2.1.10, commit=b19e9ce674, pid=14180
[2023/09/28 16:19:48] [debug] [engine] coroutine stack size: 98302 bytes (96.0K)
[2023/09/28 16:19:48] [ info] [storage] ver=1.5.1, type=memory, sync=normal, checksum=off, max_chunks_up=128
[2023/09/28 16:19:48] [ info] [cmetrics] version=0.6.3
[2023/09/28 16:19:48] [ info] [ctraces ] version=0.3.1
[2023/09/28 16:19:48] [ info] [input:random:random.0] initializing
[2023/09/28 16:19:48] [ info] [input:random:random.0] storage_strategy='memory' (memory only)
[2023/09/28 16:19:48] [debug] [random:random.0] created event channels: read=848 write=852
[2023/09/28 16:19:48] [debug] [input:random:random.0] interval_sec=1 interval_nsec=0
[2023/09/28 16:19:48] [debug] [stdout:stdout.0] created event channels: read=856 write=860
[2023/09/28 16:19:48] [ info] [sp] stream processor started
[2023/09/28 16:19:48] [ info] [output:stdout:stdout.0] worker #0 started
[2023/09/28 16:19:49] [debug] [input chunk] update output instances with new chunk size diff=50, records=1, input=random.0
[2023/09/28 16:19:50] [debug] [task] created task=0000024A94EC3ED0 id=0 OK
[0] random.0: [[1695885589.156550400, {}], {"rand_value"=>8010636517080299662}]
[2023/09/28 16:19:50] [debug] [output:stdout:stdout.0] task_id=0 assigned to thread #0
[2023/09/28 16:19:50] [debug] [input chunk] update output instances with new chunk size diff=50, records=1, input=random.0
[2023/09/28 16:19:50] [debug] [out flush] cb_destroy coro_id=0
[2023/09/28 16:19:50] [debug] [task] destroy task=0000024A94EC3ED0 (task_id=0)
[2023/09/28 16:19:51] [debug] [task] created task=0000024A94EC3ED0 id=0 OK
[0] random.0: [[[2023/09/28 16:19:51] [debug] [output:stdout:stdout.0] task_id=0 assigned to thread #0
1695885590.151422100, {}], {"rand_value"=>[2023/09/28 16:19:51] [debug] [input chunk] update output instances with new chunk size diff=50, records=1, input=random.0
16483654022445272261}]
[2023/09/28 16:19:51] [debug] [out flush] cb_destroy coro_id=1
[2023/09/28 16:19:51] [debug] [task] destroy task=0000024A94EC3ED0 (task_id=0)
[2023/09/28 16:19:52] [debug] [task] created task=0000024A94EC3ED0 id=0 OK
[2023/09/28 16:19:52] [debug] [output:stdout:stdout.0] task_id=0 assigned to thread #0
[2023/09/28 16:19:52] [debug] [input chunk] update output instances with new chunk size diff=50, records=1, input=random.0
[0] random.0: [[1695885591.136284300, {}], {"rand_value"=>14687638350890635559}]
[2023/09/28 16:19:52] [debug] [out flush] cb_destroy coro_id=2
[2023/09/28 16:19:52] [debug] [task] destroy task=0000024A94EC3ED0 (task_id=0)
[2023/09/28 16:19:53] [debug] [task] created task=0000024A94EC3ED0 id=0 OK
[2023/09/28 16:19:53] [debug] [output:stdout:stdout.0] task_id=0 assigned to thread #0
[2023/09/28 16:19:53] [debug] [input chunk] update output instances with new chunk size diff=50, records=1, input=random.0
[0] random.0: [[1695885592.148192900, {}], {"rand_value"=>2570721039374198827}]
[2023/09/28 16:19:53] [debug] [out flush] cb_destroy coro_id=3
[2023/09/28 16:19:53] [debug] [task] destroy task=0000024A94EC3ED0 (task_id=0)
[2023/09/28 16:19:54] [debug] [task] created task=0000024A94EC3ED0 id=0 OK
[0] random.0: [[1695885593.146608200, {}[2023/09/28 16:19:54] [debug] [output:stdout:stdout.0] task_id=0 assigned to thread #0
[2023/09/28 16:19:54] [debug] [input chunk] update output instances with new chunk size diff=50, records=1, input=random.0
], {"rand_value"=>14232029138453562000}]
[2023/09/28 16:19:54] [debug] [out flush] cb_destroy coro_id=4
[2023/09/28 16:19:54] [debug] [task] destroy task=0000024A94EC3ED0 (task_id=0)
[2023/09/28 16:19:55] [debug] [task] created task=0000024A94EC3ED0 id=0 OK
[0] random.0: [[[2023/09/28 16:19:55] [debug] [output:stdout:stdout.0] task_id=0 assigned to thread #0
[2023/09/28 16:19:55] [debug] [input chunk] update output instances with new chunk size diff=50, records=1, input=random.0
1695885594.156011400, {}], {"rand_value"=>12405196442465117108}]
[2023/09/28 16:19:55] [debug] [out flush] cb_destroy coro_id=5
[2023/09/28 16:19:55] [debug] [task] destroy task=0000024A94EC3ED0 (task_id=0)
[2023/09/28 16:19:55] [engine] caught signal (SIGINT)
[2023/09/28 16:19:56] [debug] [task] created task=0000024A94EC3ED0 id=0 OK
[2023/09/28 16:19:56] [debug] [output:stdout:stdout.0] task_id=0 assigned to thread #0
[2023/09/28 16:19:56] [debug] [input chunk] update output instances with new chunk size diff=50, records=1, input=random.0
[0] random.0: [[1695885595.150238200, {}], {"rand_value"=>1524614499674638143}]
[2023/09/28 16:19:56] [debug] [out flush] cb_destroy coro_id=6
[2023/09/28 16:19:56] [debug] [task] destroy task=0000024A94EC3ED0 (task_id=0)
[2023/09/28 16:19:56] [debug] [task] created task=0000024A94EC3ED0 id=0 OK
[0] random.0: [[1695885596.161630400, {}], {"rand_value"=>10902648771393957905}]
[2023/09/28 16:19:56] [debug] [output:stdout:stdout.0] task_id=0 assigned to thread #0
[2023/09/28 16:19:56] [ warn] [engine] service will shutdown in max 5 seconds
[2023/09/28 16:19:56] [debug] [out flush] cb_destroy coro_id=7
[2023/09/28 16:19:56] [ info] [input] pausing random.0
[2023/09/28 16:19:56] [debug] [task] destroy task=0000024A94EC3ED0 (task_id=0)
[2023/09/28 16:19:57] [ info] [engine] service has stopped (0 pending tasks)
[2023/09/28 16:19:57] [ info] [input] pausing random.0
[2023/09/28 16:19:57] [ info] [output:stdout:stdout.0] thread worker #0 stopping...
[2023/09/28 16:19:57] [ 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.

@cosmo0920 cosmo0920 temporarily deployed to pr September 28, 2023 07:21 — with GitHub Actions Inactive
@cosmo0920 cosmo0920 temporarily deployed to pr September 28, 2023 07:21 — with GitHub Actions Inactive
@cosmo0920 cosmo0920 temporarily deployed to pr September 28, 2023 07:21 — with GitHub Actions Inactive
After supporting fleet management on Windows,
Ctrl-C events won't be caught up.
This commit re-enables for the behavior.
Windows' ctrl event handlers stolen signals which are overlapped ones.
So, we need to handle Ctrl-C events on the newly added event handler for Windows.

In Windows, SIGINT and SIGBREAK are valid ctrl events on their terminal.
This is why we only need to handle CTRL_C_EVENT and CTRL_BREAK_EVENT events on console handler.

Signed-off-by: Hiroshi Hatake <[email protected]>
@cosmo0920 cosmo0920 force-pushed the cosmo0920-restore-ctrl-c-behavior-on-windows branch from 7523138 to deee38d Compare September 28, 2023 07:22
@cosmo0920 cosmo0920 temporarily deployed to pr September 28, 2023 07:23 — with GitHub Actions Inactive
@cosmo0920 cosmo0920 temporarily deployed to pr September 28, 2023 07:23 — with GitHub Actions Inactive
@cosmo0920 cosmo0920 temporarily deployed to pr September 28, 2023 07:23 — with GitHub Actions Inactive
Signed-off-by: Hiroshi Hatake <[email protected]>
@cosmo0920 cosmo0920 temporarily deployed to pr September 28, 2023 07:41 — with GitHub Actions Inactive
@cosmo0920 cosmo0920 temporarily deployed to pr September 28, 2023 07:41 — with GitHub Actions Inactive
@cosmo0920 cosmo0920 temporarily deployed to pr September 28, 2023 07:41 — with GitHub Actions Inactive
@cosmo0920 cosmo0920 temporarily deployed to pr September 28, 2023 08:08 — with GitHub Actions Inactive
@edsiper edsiper merged commit 14cfcdb into master Oct 2, 2023
40 of 42 checks passed
@edsiper edsiper deleted the cosmo0920-restore-ctrl-c-behavior-on-windows branch October 2, 2023 19:38
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.

Ctrl+C (SIGINT) won't be effective on Windows after fleet support on Windows is merged
2 participants