Make the return value a char *' instead of a
const char *'.
1998-12-09 Martin Baulig <martin@home-of-linux.org> * include/glibtop/procargs.h (glibtop_get_proc_args): Make the return value a `char *' instead of a `const char *'.
This commit is contained in:
committed by
Martin Baulig
parent
ee9812e9af
commit
1520ee7083
@@ -1,3 +1,8 @@
|
||||
1998-12-09 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* include/glibtop/procargs.h (glibtop_get_proc_args): Make the
|
||||
return value a `char *' instead of a `const char *'.
|
||||
|
||||
1998-12-09 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* LIBGTOP-VERSION: Set version number to 0.29.1.
|
||||
|
@@ -44,8 +44,8 @@ main (int argc, char *argv [])
|
||||
glibtop_sysdeps sysdeps;
|
||||
unsigned c, method, count, port, i, *ptr;
|
||||
char buffer [BUFSIZ];
|
||||
const char *args;
|
||||
pid_t pid, ppid;
|
||||
char *args;
|
||||
|
||||
count = PROFILE_COUNT;
|
||||
|
||||
@@ -334,6 +334,11 @@ main (int argc, char *argv [])
|
||||
|
||||
args = glibtop_get_proc_args (&data.proc_args, pid, 0);
|
||||
|
||||
for (i = 0; i < data.proc_args.size; i++) {
|
||||
if (args [i]) continue;
|
||||
args [i] = '|';
|
||||
}
|
||||
|
||||
printf ("Proc_Args PID %5d (0x%08lx): %lu - '%s'\n", (int) pid,
|
||||
(unsigned long) data.proc_args.flags,
|
||||
(unsigned long) data.proc_args.size,
|
||||
@@ -439,6 +444,11 @@ main (int argc, char *argv [])
|
||||
|
||||
args = glibtop_get_proc_args (&data.proc_args, ppid, 0);
|
||||
|
||||
for (i = 0; i < data.proc_args.size; i++) {
|
||||
if (args [i]) continue;
|
||||
args [i] = '|';
|
||||
}
|
||||
|
||||
printf ("Proc_Args PID %5d (0x%08lx): %lu - '%s'\n", (int) ppid,
|
||||
(unsigned long) data.proc_args.flags,
|
||||
(unsigned long) data.proc_args.size,
|
||||
@@ -545,6 +555,11 @@ main (int argc, char *argv [])
|
||||
|
||||
args = glibtop_get_proc_args (&data.proc_args, 1, 0);
|
||||
|
||||
for (i = 0; i < data.proc_args.size; i++) {
|
||||
if (args [i]) continue;
|
||||
args [i] = '|';
|
||||
}
|
||||
|
||||
printf ("Proc_Args PID %5d (0x%08lx): %lu - '%s'\n", 1,
|
||||
(unsigned long) data.proc_args.flags,
|
||||
(unsigned long) data.proc_args.size,
|
||||
|
@@ -36,13 +36,15 @@ output (pid_t pid)
|
||||
{
|
||||
glibtop_union data;
|
||||
char *args;
|
||||
unsigned i;
|
||||
|
||||
#if HAVE_LIBGTOP_SMP
|
||||
unsigned long total;
|
||||
double p_total, p_utime, p_stime;
|
||||
double b_total, b_utime, b_stime;
|
||||
double s_total, s_utime, s_stime;
|
||||
double my_utime, my_stime;
|
||||
int ncpu, i;
|
||||
int ncpu;
|
||||
#endif
|
||||
|
||||
printf ("\n");
|
||||
@@ -138,6 +140,11 @@ output (pid_t pid)
|
||||
|
||||
args = glibtop_get_proc_args (&data.proc_args, pid, 0);
|
||||
|
||||
for (i = 0; i < data.proc_args.size; i++) {
|
||||
if (args [i]) continue;
|
||||
args [i] = '|';
|
||||
}
|
||||
|
||||
printf ("Proc_Args PID %5d (0x%08lx): %lu - '%s'\n", (int) pid,
|
||||
(unsigned long) data.proc_args.flags,
|
||||
(unsigned long) data.proc_args.size,
|
||||
|
@@ -14,7 +14,7 @@ void|proc_time|long(start_time,rtime,utime,stime,cutime,cstime,timeout,it_real_v
|
||||
void|proc_signal|ulong(signal[2],blocked[2],sigignore[2],sigcatch[2])|pid_t(pid)
|
||||
void|proc_kernel|ulong(k_flags,min_flt,maj_flt,cmin_flt,cmaj_flt,kstk_esp,kstk_eip,nwchan):str(wchan)|pid_t(pid)
|
||||
void|proc_segment|ulong(text_rss,shlib_rss,data_rss,stack_rss,dirty_size,start_code,end_code,start_stack)|pid_t(pid)
|
||||
const char *|proc_args|ulong(size)|pid_t(pid):unsigned(max_len)
|
||||
char *|proc_args|ulong(size)|pid_t(pid):unsigned(max_len)
|
||||
glibtop_map_entry *|proc_map|ulong(number,size,total)|pid_t(pid)
|
||||
glibtop_mountentry *|@mountlist|ulong(number,size,total)|int(all_fs)
|
||||
void|@fsusage|ulong(blocks,bfree,bavail,files,ffree)|string|mount_dir
|
||||
|
@@ -47,14 +47,14 @@ struct _glibtop_proc_args
|
||||
#define glibtop_get_proc_args_r glibtop_get_proc_args_s
|
||||
#endif
|
||||
|
||||
extern const char *glibtop_get_proc_args_l __P((glibtop *, glibtop_proc_args *, pid_t, unsigned));
|
||||
extern char *glibtop_get_proc_args_l __P((glibtop *, glibtop_proc_args *, pid_t, unsigned));
|
||||
|
||||
#if GLIBTOP_SUID_PROC_ARGS
|
||||
extern void glibtop_init_proc_args_p __P((glibtop *));
|
||||
extern const char *glibtop_get_proc_args_p __P((glibtop *, glibtop_proc_args *, pid_t, unsigned));
|
||||
extern char *glibtop_get_proc_args_p __P((glibtop *, glibtop_proc_args *, pid_t, unsigned));
|
||||
#else
|
||||
extern void glibtop_init_proc_args_s __P((glibtop *));
|
||||
extern const char *glibtop_get_proc_args_s __P((glibtop *, glibtop_proc_args *, pid_t, unsigned));
|
||||
extern char *glibtop_get_proc_args_s __P((glibtop *, glibtop_proc_args *, pid_t, unsigned));
|
||||
#endif
|
||||
|
||||
#ifdef GLIBTOP_NAMES
|
||||
|
@@ -43,7 +43,7 @@ glibtop_init_proc_args_p (glibtop *server)
|
||||
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
const char *
|
||||
char *
|
||||
glibtop_get_proc_args_p (glibtop *server, glibtop_proc_args *buf,
|
||||
pid_t pid, unsigned max_len)
|
||||
{
|
||||
|
@@ -1,3 +1,8 @@
|
||||
1998-12-09 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* procargs.c (glibtop_get_proc_args_s): Added implementation
|
||||
for this function.
|
||||
|
||||
1998-12-03 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* netload.c: No longer include <linux/version.h>, but use
|
||||
|
@@ -24,7 +24,8 @@
|
||||
#include <glibtop/xmalloc.h>
|
||||
#include <glibtop/procargs.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_proc_args = 0;
|
||||
static const unsigned long _glibtop_sysdeps_proc_args =
|
||||
(1 << GLIBTOP_PROC_ARGS_SIZE);
|
||||
|
||||
/* Init function. */
|
||||
|
||||
@@ -36,10 +37,55 @@ glibtop_init_proc_args_s (glibtop *server)
|
||||
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
const char *
|
||||
char *
|
||||
glibtop_get_proc_args_s (glibtop *server, glibtop_proc_args *buf,
|
||||
pid_t pid, unsigned max_len)
|
||||
{
|
||||
char fn [BUFSIZ], buffer [BUFSIZ];
|
||||
int cmdline, len, total = 0;
|
||||
char *retval = NULL;
|
||||
|
||||
glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_ARGS, 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proc_args));
|
||||
return NULL;
|
||||
|
||||
sprintf (fn, "/proc/%d/cmdline", pid);
|
||||
|
||||
cmdline = open (fn, O_RDONLY);
|
||||
if (cmdline < 0) return NULL;
|
||||
|
||||
if (max_len) {
|
||||
retval = glibtop_malloc_r (server, max_len+1);
|
||||
|
||||
len = read (cmdline, retval, max_len);
|
||||
if (len < 0) {
|
||||
glibtop_free_r (server, retval);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
len = read (cmdline, buffer, BUFSIZ-1);
|
||||
if (len < 0) {
|
||||
glibtop_free_r (server, retval);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (len == 0)
|
||||
break;
|
||||
|
||||
retval = glibtop_realloc_r (server, retval, total+len+1);
|
||||
memcpy (retval+total, buffer, len);
|
||||
*(retval+total+len) = 0;
|
||||
total += len;
|
||||
}
|
||||
|
||||
close (cmdline);
|
||||
|
||||
buf->size = total;
|
||||
buf->flags = _glibtop_sysdeps_proc_args;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ glibtop_init_proc_args_s (glibtop *server)
|
||||
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
const char *
|
||||
char *
|
||||
glibtop_get_proc_args_s (glibtop *server, glibtop_proc_args *buf,
|
||||
pid_t pid, unsigned max_len)
|
||||
{
|
||||
|
@@ -36,7 +36,7 @@ glibtop_init_proc_args_p (glibtop *server)
|
||||
|
||||
/* Provides detailed information about a process. */
|
||||
|
||||
const char *
|
||||
char *
|
||||
glibtop_get_proc_args_p (glibtop *server, glibtop_proc_args *buf,
|
||||
pid_t pid, unsigned max_len)
|
||||
{
|
||||
|
Reference in New Issue
Block a user