Skip to content

Commit

Permalink
TerminalShell: ignore the parent process if $FFTS_IGNORE_PARENT is …
Browse files Browse the repository at this point in the history
…set to `1`

Fix fastfetch-cli#1205
  • Loading branch information
CarterLi committed Aug 23, 2024
1 parent d58e37e commit 6eec888
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/detection/terminalshell/terminalshell_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions src/detection/terminalshell/terminalshell_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6eec888

Please sign in to comment.