From b0e19126e40c6e49678f48e31ffba8024e87b228 Mon Sep 17 00:00:00 2001 From: Daniel Cazzulino Date: Sat, 24 Oct 2026 03:33:52 -0300 Subject: [PATCH] Set NDX_LAUNCHED so a launched tool can tell ndx started it. --- src/Tests/ToolLauncherTests.cs | 1 + src/ndx/ProcessStartSettings.cs | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Tests/ToolLauncherTests.cs b/src/Tests/ToolLauncherTests.cs index 7320f23..999e18e 100644 --- a/src/Tests/ToolLauncherTests.cs +++ b/src/Tests/ToolLauncherTests.cs @@ -56,5 +56,6 @@ public void ToStartInfo_preserves_no_shell_and_no_redirect() Assert.False(start.RedirectStandardOutput); Assert.False(start.RedirectStandardError); Assert.Equal(["--flag"], start.ArgumentList.ToArray()); + Assert.Equal("1", start.Environment["NDX_LAUNCHED"]); } } diff --git a/src/ndx/ProcessStartSettings.cs b/src/ndx/ProcessStartSettings.cs index edbaf53..9a27a7c 100644 --- a/src/ndx/ProcessStartSettings.cs +++ b/src/ndx/ProcessStartSettings.cs @@ -4,7 +4,8 @@ namespace ndx; /// /// Process start settings for the downloaded tool. ndx always starts the child -/// without a shell and with inherited standard in/out/error. +/// without a shell, with inherited standard in/out/error, and with +/// NDX_LAUNCHED=1 so the child can tell it was started by ndx. /// public sealed record ProcessStartSettings { @@ -33,6 +34,8 @@ public ProcessStartInfo ToStartInfo() foreach (var argument in Arguments) start.ArgumentList.Add(argument); + start.Environment["NDX_LAUNCHED"] = "1"; + return start; } }