TerminalShell: ignore the parent process if $FFTS_IGNORE_PARENT is set to 1

Fix #1205
This commit is contained in:
李通洲
2024-08-23 15:52:14 +08:00
parent 893b3a6bff
commit f22b8ede02
2 changed files with 12 additions and 0 deletions
@@ -384,6 +384,14 @@ const FFShellResult* ffDetectShell()
result.tty = -1;
pid_t ppid = getppid();
const char* ignoreParent = getenv("FFTS_IGNORE_PARENT");
if (ignoreParent && ffStrEquals(ignoreParent, "1"))
{
FF_STRBUF_AUTO_DESTROY _ = ffStrbufCreate();
ffProcessGetBasicInfoLinux(ppid, &_, &ppid, NULL);
}
ppid = getShellInfo(&result, ppid);
getUserShellFromEnv(&result);
setShellInfoDetails(&result);
@@ -345,6 +345,10 @@ const FFShellResult* ffDetectShell(void)
if(!ffProcessGetInfoWindows(0, &ppid, NULL, NULL, NULL, NULL, NULL))
return &result;
const char* ignoreParent = getenv("FFTS_IGNORE_PARENT");
if (ignoreParent && ffStrEquals(ignoreParent, "1"))
ffProcessGetInfoWindows(ppid, &ppid, NULL, NULL, NULL, NULL, NULL);
ppid = getShellInfo(&result, ppid);
if (result.processName.length > 0)