Skip to content

Commit 8dc4f77

Browse files
committed
Shell (Haiku): fix arg0 detection
1 parent ab0240e commit 8dc4f77

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/common/processing_linux.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -319,17 +319,20 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons
319319
team_info info;
320320
if (get_team_info(pid, &info) == B_OK)
321321
{
322-
// This is tricky. info.args is not encoded, so that we don't know if
323-
// a whitespace in args is part of the file path or an argument separator
322+
// This is tricky. Paths in info.args are not quoted, so that we don't know
323+
// if a whitespace in args is part of the file path or an argument separator
324324
if (info.argc == 1)
325325
ffStrbufSetS(exe, info.args);
326326
else
327327
{
328-
int argc = info.argc;
329-
for (const char* p = info.args; (p = strchr(p, ' ')); ++p)
328+
// args = "/bin/bash -l"
329+
// argc = 2
330+
int argc = info.argc - 1; // 1
331+
const char* arg0End = strchr(p, ' '); // " -l"
332+
for (const char* p = arg0End + 1; (p = strchr(p, ' ')); ++p)
330333
--argc;
331334
if (argc == 1)
332-
ffStrbufSetS(exe, info.args);
335+
ffStrbufSetNS(exe, info.args, arg0End - info.args /* /bin/bash */);
333336
}
334337
}
335338
}

0 commit comments

Comments
 (0)