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
0969f83b
Commit
0969f83b
authored
Mar 29, 2018
by
Guy M. Broome
Committed by
Hisham Muhammad
Apr 05, 2018
Browse files
Solaris: Implement process environment listing
parent
155d7cbe
Changes
2
Show whitespace changes
Inline
Side-by-side
solaris/Platform.c
View file @
0969f83b
...
...
@@ -37,12 +37,21 @@ in the source distribution for its full text.
#include "SignalsPanel.h"
#include <signal.h>
#include <sys/mkdev.h>
#include <sys/proc.h>
#include <libproc.h>
#define kill(pid, signal) kill(pid / 1024, signal)
extern ProcessFieldData Process_fields[];
typedef struct var kvar_t;
typedef struct envAccum_ {
size_t capacity;
size_t size;
size_t bytes;
char *env;
} envAccum;
}*/
double
plat_loadavg
[
3
]
=
{
0
};
...
...
@@ -211,7 +220,38 @@ void Platform_setSwapValues(Meter* this) {
this
->
values
[
0
]
=
pl
->
usedSwap
;
}
static
int
Platform_buildenv
(
void
*
accum
,
struct
ps_prochandle
*
Phandle
,
uintptr_t
addr
,
const
char
*
str
)
{
envAccum
*
accump
=
accum
;
(
void
)
Phandle
;
(
void
)
addr
;
size_t
thissz
=
strlen
(
str
);
if
((
thissz
+
2
)
>
(
accump
->
capacity
-
accump
->
size
))
accump
->
env
=
xRealloc
(
accump
->
env
,
accump
->
capacity
*=
2
);
if
((
thissz
+
2
)
>
(
accump
->
capacity
-
accump
->
size
))
return
1
;
strlcpy
(
accump
->
env
+
accump
->
size
,
str
,
(
accump
->
capacity
-
accump
->
size
));
strncpy
(
accump
->
env
+
accump
->
size
+
thissz
+
1
,
"
\n
"
,
1
);
accump
->
size
=
accump
->
size
+
thissz
+
1
;
return
0
;
}
char
*
Platform_getProcessEnv
(
pid_t
pid
)
{
(
void
)
pid
;
return
"Not (yet) supported on Solaris. Sorry!"
;
envAccum
envBuilder
;
pid_t
realpid
=
pid
/
1024
;
int
graberr
;
struct
ps_prochandle
*
Phandle
;
if
((
Phandle
=
Pgrab
(
realpid
,
PGRAB_RDONLY
,
&
graberr
))
==
NULL
)
return
"Unable to read process environment."
;
envBuilder
.
capacity
=
4096
;
envBuilder
.
size
=
0
;
envBuilder
.
env
=
xMalloc
(
envBuilder
.
capacity
);
(
void
)
Penv_iter
(
Phandle
,
Platform_buildenv
,
&
envBuilder
);
Prelease
(
Phandle
,
0
);
strncpy
(
envBuilder
.
env
+
envBuilder
.
size
,
"
\0
"
,
1
);
return
envBuilder
.
env
;
}
solaris/Platform.h
View file @
0969f83b
...
...
@@ -16,12 +16,21 @@ in the source distribution for its full text.
#include "SignalsPanel.h"
#include <signal.h>
#include <sys/mkdev.h>
#include <sys/proc.h>
#include <libproc.h>
#define kill(pid, signal) kill(pid / 1024, signal)
extern
ProcessFieldData
Process_fields
[];
typedef
struct
var
kvar_t
;
typedef
struct
envAccum_
{
size_t
capacity
;
size_t
size
;
size_t
bytes
;
char
*
env
;
}
envAccum
;
extern
double
plat_loadavg
[
3
];
...
...
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