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
259e1a29
Commit
259e1a29
authored
Oct 20, 2012
by
Hisham Muhammad
Browse files
fixes PGRP and SESN columns in case of big pids. Patch #3567904.
parent
f44a8f20
Changes
1
Hide whitespace changes
Inline
Side-by-side
Process.c
View file @
259e1a29
...
@@ -208,7 +208,7 @@ const char *Process_fieldNames[] = {
...
@@ -208,7 +208,7 @@ const char *Process_fieldNames[] = {
};
};
const
char
*
Process_fieldTitles
[]
=
{
const
char
*
Process_fieldTitles
[]
=
{
""
,
" PID "
,
"Command "
,
"S "
,
" PPID "
,
" PGRP "
,
" SESN "
,
""
,
" PID "
,
"Command "
,
"S "
,
" PPID "
,
"
PGRP "
,
"
SESN "
,
" TTY "
,
" TPGID "
,
"- "
,
"- "
,
"- "
,
"- "
,
"- "
,
" TTY "
,
" TPGID "
,
"- "
,
"- "
,
"- "
,
"- "
,
"- "
,
" UTIME+ "
,
" STIME+ "
,
" CUTIME+ "
,
" CSTIME+ "
,
"PRI "
,
" NI "
,
"- "
,
" UTIME+ "
,
" STIME+ "
,
" CUTIME+ "
,
" CSTIME+ "
,
"PRI "
,
" NI "
,
"- "
,
"START "
,
"- "
,
"- "
,
"- "
,
"- "
,
"- "
,
"- "
,
"START "
,
"- "
,
"- "
,
"- "
,
"- "
,
"- "
,
"- "
,
...
@@ -245,17 +245,21 @@ void Process_getMaxPid() {
...
@@ -245,17 +245,21 @@ void Process_getMaxPid() {
fscanf
(
file
,
"%32d"
,
&
maxPid
);
fscanf
(
file
,
"%32d"
,
&
maxPid
);
fclose
(
file
);
fclose
(
file
);
if
(
maxPid
>
99999
)
{
if
(
maxPid
>
99999
)
{
Process_fieldTitles
[
PID
]
=
" PID "
;
Process_fieldTitles
[
PID
]
=
" PID "
;
Process_fieldTitles
[
PPID
]
=
" PPID "
;
Process_fieldTitles
[
PPID
]
=
" PPID "
;
Process_fieldTitles
[
TPGID
]
=
" TPGID "
;
Process_fieldTitles
[
TPGID
]
=
" TPGID "
;
Process_fieldTitles
[
TGID
]
=
" TGID "
;
Process_fieldTitles
[
TGID
]
=
" TGID "
;
Process_fieldTitles
[
PGRP
]
=
" PGRP "
;
Process_fieldTitles
[
SESSION
]
=
" SESN "
;
Process_pidFormat
=
"%7u "
;
Process_pidFormat
=
"%7u "
;
Process_tpgidFormat
=
"%7d "
;
Process_tpgidFormat
=
"%7d "
;
}
else
{
}
else
{
Process_fieldTitles
[
PID
]
=
" PID "
;
Process_fieldTitles
[
PID
]
=
" PID "
;
Process_fieldTitles
[
PPID
]
=
" PPID "
;
Process_fieldTitles
[
PPID
]
=
" PPID "
;
Process_fieldTitles
[
TPGID
]
=
"TPGID "
;
Process_fieldTitles
[
TPGID
]
=
"TPGID "
;
Process_fieldTitles
[
TGID
]
=
" TGID "
;
Process_fieldTitles
[
TGID
]
=
" TGID "
;
Process_fieldTitles
[
PGRP
]
=
" PGRP "
;
Process_fieldTitles
[
SESSION
]
=
" SESN "
;
Process_pidFormat
=
"%5u "
;
Process_pidFormat
=
"%5u "
;
Process_tpgidFormat
=
"%5d "
;
Process_tpgidFormat
=
"%5d "
;
}
}
...
@@ -381,8 +385,8 @@ static void Process_writeField(Process* this, RichString* str, ProcessField fiel
...
@@ -381,8 +385,8 @@ static void Process_writeField(Process* this, RichString* str, ProcessField fiel
switch
(
field
)
{
switch
(
field
)
{
case
PID
:
snprintf
(
buffer
,
n
,
Process_pidFormat
,
this
->
pid
);
break
;
case
PID
:
snprintf
(
buffer
,
n
,
Process_pidFormat
,
this
->
pid
);
break
;
case
PPID
:
snprintf
(
buffer
,
n
,
Process_pidFormat
,
this
->
ppid
);
break
;
case
PPID
:
snprintf
(
buffer
,
n
,
Process_pidFormat
,
this
->
ppid
);
break
;
case
PGRP
:
snprintf
(
buffer
,
n
,
"%5u "
,
this
->
pgrp
);
break
;
case
PGRP
:
snprintf
(
buffer
,
n
,
Process_pidFormat
,
this
->
pgrp
);
break
;
case
SESSION
:
snprintf
(
buffer
,
n
,
"%5u "
,
this
->
session
);
break
;
case
SESSION
:
snprintf
(
buffer
,
n
,
Process_pidFormat
,
this
->
session
);
break
;
case
TTY_NR
:
snprintf
(
buffer
,
n
,
"%5u "
,
this
->
tty_nr
);
break
;
case
TTY_NR
:
snprintf
(
buffer
,
n
,
"%5u "
,
this
->
tty_nr
);
break
;
case
TGID
:
snprintf
(
buffer
,
n
,
Process_pidFormat
,
this
->
tgid
);
break
;
case
TGID
:
snprintf
(
buffer
,
n
,
Process_pidFormat
,
this
->
tgid
);
break
;
case
TPGID
:
snprintf
(
buffer
,
n
,
Process_tpgidFormat
,
this
->
tpgid
);
break
;
case
TPGID
:
snprintf
(
buffer
,
n
,
Process_tpgidFormat
,
this
->
tpgid
);
break
;
...
...
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