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
cf7fdcd1
Commit
cf7fdcd1
authored
Dec 17, 2007
by
Hisham Muhammad
Browse files
Experimental feature: beep on permission failures.
Update dates.
parent
a839c3f2
Changes
3
Show whitespace changes
Inline
Side-by-side
Process.c
View file @
cf7fdcd1
...
...
@@ -42,7 +42,7 @@ typedef enum ProcessField_ {
STIME, CUTIME, CSTIME, PRIORITY, NICE, ITREALVALUE, STARTTIME, VSIZE, RSS, RLIM, STARTCODE, ENDCODE,
STARTSTACK, KSTKESP, KSTKEIP, SIGNAL, BLOCKED, SSIGIGNORE, SIGCATCH, WCHAN, NSWAP, CNSWAP, EXIT_SIGNAL,
PROCESSOR, M_SIZE, M_RESIDENT, M_SHARE, M_TRS, M_DRS, M_LRS, M_DT, ST_UID, PERCENT_CPU, PERCENT_MEM,
USER, TIME, NLWP, TGID
USER, TIME, NLWP, TGID
,
#ifdef HAVE_OPENVZ
VEID, VPID,
#endif
...
...
@@ -187,12 +187,13 @@ void Process_toggleTag(Process* this) {
this
->
tag
=
this
->
tag
==
true
?
false
:
true
;
}
void
Process_setPriority
(
Process
*
this
,
int
priority
)
{
bool
Process_setPriority
(
Process
*
this
,
int
priority
)
{
int
old_prio
=
getpriority
(
PRIO_PROCESS
,
this
->
pid
);
int
err
=
setpriority
(
PRIO_PROCESS
,
this
->
pid
,
priority
);
if
(
err
==
0
&&
old_prio
!=
getpriority
(
PRIO_PROCESS
,
this
->
pid
))
{
this
->
nice
=
priority
;
}
return
(
err
==
0
);
}
unsigned
long
Process_getAffinity
(
Process
*
this
)
{
...
...
@@ -201,8 +202,8 @@ unsigned long Process_getAffinity(Process* this) {
return
mask
;
}
void
Process_setAffinity
(
Process
*
this
,
unsigned
long
mask
)
{
sched_setaffinity
(
this
->
pid
,
sizeof
(
unsigned
long
),
(
cpu_set_t
*
)
&
mask
);
bool
Process_setAffinity
(
Process
*
this
,
unsigned
long
mask
)
{
return
(
sched_setaffinity
(
this
->
pid
,
sizeof
(
unsigned
long
),
(
cpu_set_t
*
)
&
mask
)
==
0
)
;
}
void
Process_sendSignal
(
Process
*
this
,
int
signal
)
{
...
...
Process.h
View file @
cf7fdcd1
...
...
@@ -141,11 +141,11 @@ void Process_display(Object* cast, RichString* out);
void
Process_toggleTag
(
Process
*
this
);
void
Process_setPriority
(
Process
*
this
,
int
priority
);
bool
Process_setPriority
(
Process
*
this
,
int
priority
);
unsigned
long
Process_getAffinity
(
Process
*
this
);
void
Process_setAffinity
(
Process
*
this
,
unsigned
long
mask
);
bool
Process_setAffinity
(
Process
*
this
,
unsigned
long
mask
);
void
Process_sendSignal
(
Process
*
this
,
int
signal
);
...
...
htop.c
View file @
cf7fdcd1
/*
htop - htop.c
(C) 2004-200
6
Hisham H. Muhammad
(C) 2004-200
7
Hisham H. Muhammad
Released under the GNU GPL, see the COPYING file
in the source distribution for its full text.
*/
...
...
@@ -36,14 +36,14 @@ in the source distribution for its full text.
void
printVersionFlag
()
{
clear
();
printf
(
"htop "
VERSION
" - (C) 2004-200
6
Hisham Muhammad.
\n
"
);
printf
(
"htop "
VERSION
" - (C) 2004-200
7
Hisham Muhammad.
\n
"
);
printf
(
"Released under the GNU GPL.
\n\n
"
);
exit
(
0
);
}
void
printHelpFlag
()
{
clear
();
printf
(
"htop "
VERSION
" - (C) 2004-200
6
Hisham Muhammad.
\n
"
);
printf
(
"htop "
VERSION
" - (C) 2004-200
7
Hisham Muhammad.
\n
"
);
printf
(
"Released under the GNU GPL.
\n\n
"
);
printf
(
"-d DELAY Delay between updates, in tenths of seconds
\n\n
"
);
printf
(
"-u USERNAME Show only processes of a given user
\n\n
"
);
...
...
@@ -56,7 +56,7 @@ void printHelpFlag() {
void
showHelp
(
ProcessList
*
pl
)
{
clear
();
attrset
(
CRT_colors
[
HELP_BOLD
]);
mvaddstr
(
0
,
0
,
"htop "
VERSION
" - (C) 2004-200
6
Hisham Muhammad."
);
mvaddstr
(
0
,
0
,
"htop "
VERSION
" - (C) 2004-200
7
Hisham Muhammad."
);
mvaddstr
(
1
,
0
,
"Released under the GNU GPL. See 'man' page for more info."
);
attrset
(
CRT_colors
[
DEFAULT_COLOR
]);
...
...
@@ -151,18 +151,21 @@ static void Setup_run(Settings* settings, int headerHeight) {
}
static
bool
changePriority
(
Panel
*
panel
,
int
delta
)
{
bool
ok
=
true
;
bool
anyTagged
=
false
;
for
(
int
i
=
0
;
i
<
Panel_getSize
(
panel
);
i
++
)
{
Process
*
p
=
(
Process
*
)
Panel_get
(
panel
,
i
);
if
(
p
->
tag
)
{
Process_setPriority
(
p
,
p
->
nice
+
delta
);
ok
=
Process_setPriority
(
p
,
p
->
nice
+
delta
)
&&
ok
;
anyTagged
=
true
;
}
}
if
(
!
anyTagged
)
{
Process
*
p
=
(
Process
*
)
Panel_getSelected
(
panel
);
Process_setPriority
(
p
,
p
->
nice
+
delta
);
ok
=
Process_setPriority
(
p
,
p
->
nice
+
delta
)
&&
ok
;
}
if
(
!
ok
)
beep
();
return
anyTagged
;
}
...
...
@@ -608,20 +611,25 @@ int main(int argc, char** argv) {
Panel
*
affinityPanel
=
AffinityPanel_new
(
pl
->
processorCount
,
curr
);
char
*
fuFunctions
[
2
]
=
{
"Toggle "
,
"Done "
};
pickFromList
(
panel
,
affinityPanel
,
15
,
headerHeight
,
fuFunctions
,
defaultBar
);
char
*
fuFunctions
[
2
]
=
{
"Set "
,
"Cancel "
};
void
*
set
=
pickFromList
(
panel
,
affinityPanel
,
15
,
headerHeight
,
fuFunctions
,
defaultBar
);
if
(
set
)
{
unsigned
long
new
=
AffinityPanel_getAffinity
(
affinityPanel
);
bool
anyTagged
=
false
;
bool
ok
=
true
;
for
(
int
i
=
0
;
i
<
Panel_getSize
(
panel
);
i
++
)
{
Process
*
p
=
(
Process
*
)
Panel_get
(
panel
,
i
);
if
(
p
->
tag
)
{
Process_setAffinity
(
p
,
new
);
ok
=
Process_setAffinity
(
p
,
new
)
&&
ok
;
anyTagged
=
true
;
}
}
if
(
!
anyTagged
)
{
Process
*
p
=
(
Process
*
)
Panel_getSelected
(
panel
);
Process_setAffinity
(
p
,
new
);
ok
=
Process_setAffinity
(
p
,
new
)
&&
ok
;
}
if
(
!
ok
)
beep
();
}
((
Object
*
)
affinityPanel
)
->
delete
((
Object
*
)
affinityPanel
);
Panel_setRichHeader
(
panel
,
ProcessList_printHeader
(
pl
));
...
...
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