Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
htop
Commits
bd5d37f2
Commit
bd5d37f2
authored
Aug 24, 2016
by
Hisham
Browse files
Return when reading cmdline fails (e.g. zombie process)
parent
16406ea3
Changes
1
Hide whitespace changes
Inline
Side-by-side
linux/LinuxProcessList.c
View file @
bd5d37f2
...
...
@@ -471,23 +471,25 @@ static bool LinuxProcessList_readCmdlineFile(Process* process, const char* dirna
close
(
fd
);
int
tokenEnd
=
0
;
int
lastChar
=
0
;
if
(
amtRead
>
0
)
{
for
(
int
i
=
0
;
i
<
amtRead
;
i
++
)
if
(
command
[
i
]
==
'\0'
||
command
[
i
]
==
'\n'
)
{
if
(
tokenEnd
==
0
)
{
tokenEnd
=
i
;
}
command
[
i
]
=
' '
;
}
else
{
lastChar
=
i
;
if
(
amtRead
<=
0
)
{
return
false
;
}
for
(
int
i
=
0
;
i
<
amtRead
;
i
++
)
{
if
(
command
[
i
]
==
'\0'
||
command
[
i
]
==
'\n'
)
{
if
(
tokenEnd
==
0
)
{
tokenEnd
=
i
;
}
command
[
i
]
=
' '
;
}
else
{
lastChar
=
i
;
}
}
if
(
tokenEnd
==
0
)
{
tokenEnd
=
amtRead
;
}
command
[
lastChar
+
1
]
=
'\0'
;
process
->
basenameOffset
=
tokenEnd
;
setCommand
(
process
,
command
,
lastChar
+
1
);
setCommand
(
process
,
command
,
lastChar
);
return
true
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment