CLI: Set defaults for signal arguments in stop/kill commands, update help documentation (#41348)
David Bennett committed
Aug 13, 2026 at 15:00 UTC
18c51a968fdf3fed34be2ae6712780df8a2beeef
3 files changed
+14
-13
localization/strings/en-US/Resources.resw
+9
-3
@@ -2633,10 +2633,11 @@ Example: tar -cf - files | wslc container cp - CONTAINER:/path</value>
2633
<value>Display detailed information about a container.</value>
2634
</data>
2635
<data name="WSLCCLI_ContainerKillDesc" xml:space="preserve">
2636
- <value>Kill containers.</value>
2636
+ <value>Kill one or more running containers.</value>
2637
</data>
2638
<data name="WSLCCLI_ContainerKillLongDesc" xml:space="preserve">
2639
- <value>Kills containers.</value>
2639
+ <value>Kills one or more running containers by sending SIGKILL by default, or the signal specified with --signal.</value>
2640
+ <comment>{Locked="--signal."}Command line arguments, file names and string inserts should not be translated</comment>
2641
</data>
2642
<data name="WSLCCLI_ContainerListDesc" xml:space="preserve">
2643
<value>List containers.</value>
@@ -2692,6 +2693,10 @@ Example: tar -cf - files | wslc container cp - CONTAINER:/path</value>
2693
<data name="WSLCCLI_ContainerStopLongDesc" xml:space="preserve">
2694
<value>Stops containers.</value>
2695
</data>
2696
+ <data name="WSLCCLI_ContainerStopSignalArgDescription" xml:space="preserve">
2697
+ <value>Signal to send (default: the container's configured STOPSIGNAL, or SIGTERM if none is configured)</value>
2698
+ <comment>{Locked="STOPSIGNAL"}{Locked="SIGTERM"}Command line arguments should not be translated</comment>
2699
+ </data>
2700
<data name="WSLCCLI_ImageCommandDesc" xml:space="preserve">
2701
<value>Manage images.</value>
2702
</data>
@@ -3158,7 +3163,8 @@ On first run, creates the file with all settings commented out at their defaults
3163
<value>Path to the session storage directory</value>
3164
</data>
3165
<data name="WSLCCLI_SignalArgDescription" xml:space="preserve">
3161
- <value>Signal to send</value>
3166
+ <value>Signal to send to the container (default: SIGKILL)</value>
3167
+ <comment>{Locked="SIGKILL"}Command line arguments should not be translated</comment>
3168
</data>
3169
<data name="WSLCCLI_SourceArgDescription" xml:space="preserve">
3170
<value>Current or existing image reference in the image-name[:tag] format</value>
src/windows/wslc/commands/ContainerStopCommand.cpp
+1
-1
@@ -28,7 +28,7 @@ std::vector<Argument> ContainerStopCommand::GetArguments() const
28
{
29
return {
30
Argument::Create(ArgType::ContainerId, true, Limit::Unlimited),
31
- Argument::Create(ArgType::Signal),
31
+ Argument::Create(ArgType::Signal, std::nullopt, std::nullopt, Localization::WSLCCLI_ContainerStopSignalArgDescription()),
32
Argument::Create(ArgType::Time),
33
};
34
}
src/windows/wslc/tasks/ContainerTasks.cpp
+4
-9
@@ -237,11 +237,7 @@ void KillContainers(CLIExecutionContext& context)
237
WI_ASSERT(context.Data.Contains(Data::Session));
238
auto& session = context.Data.Get<Data::Session>();
239
auto containerIds = context.Args.GetAllValues<ArgType::ContainerId>();
240
- WSLCSignal signal = WSLCSignalSIGKILL;
241
- if (context.Args.Contains(ArgType::Signal))
242
- {
243
- signal = context.Args.GetValue<ArgType::Signal>();
244
- }
240
+ const auto signal = context.Args.GetValue<ArgType::Signal>(WSLCSignalSIGKILL);
241
242
for (const auto& id : containerIds)
243
{
@@ -1025,10 +1021,9 @@ void StopContainers(CLIExecutionContext& context)
1021
auto& session = context.Data.Get<Data::Session>();
1022
auto containersToStop = context.Args.GetAllValues<ArgType::ContainerId>();
1023
StopContainerOptions options;
1028
- if (context.Args.Contains(ArgType::Signal))
1029
- {
1030
- options.Signal = context.Args.GetValue<ArgType::Signal>();
1031
- }
1024
+
1025
+ // WSLCSignalNone lets Docker use the container's configured STOPSIGNAL, or its default when none is configured.
1026
+ options.Signal = context.Args.GetValue<ArgType::Signal>(WSLCSignalNone);
1027
1028
if (context.Args.Contains(ArgType::Time))
1029
{