Did some more work on the daemon.

This commit is contained in:
Martin Baulig
1998-06-14 21:32:00 +00:00
parent 2a281d0a53
commit 8d78559597
12 changed files with 443 additions and 77 deletions

View File

@@ -16,8 +16,8 @@ bin_PROGRAMS = first first_static second second_static \
EXTRA_PROGRAMS = third third_static EXTRA_PROGRAMS = third third_static
first_SOURCES = first.c first_SOURCES = first.c
first_LDADD = $(top_builddir)/sysdeps/common/libgtop_common.la \ first_LDADD = $(top_builddir)/lib/libgtop.la \
$(top_builddir)/lib/libgtop.la \ $(top_builddir)/sysdeps/common/libgtop_common.la \
$(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \ $(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \
@INTLLIBS@ @LIBSUPPORT@ @libs_xauth@ @INTLLIBS@ @LIBSUPPORT@ @libs_xauth@
@@ -26,8 +26,8 @@ first_static_LDADD = $(first_LDADD)
first_static_LDFLAGS = -static first_static_LDFLAGS = -static
second_SOURCES = second.c second_SOURCES = second.c
second_LDADD = $(top_builddir)/sysdeps/common/libgtop_common.la \ second_LDADD = $(top_builddir)/lib/libgtop.la \
$(top_builddir)/lib/libgtop.la \ $(top_builddir)/sysdeps/common/libgtop_common.la \
$(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \ $(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \
@INTLLIBS@ @LIBSUPPORT@ @libs_xauth@ @INTLLIBS@ @LIBSUPPORT@ @libs_xauth@

View File

@@ -51,14 +51,9 @@ int
main (int argc, char *argv[]) main (int argc, char *argv[])
{ {
int s; /* socket / msqid to server */ int s; /* socket / msqid to server */
int connect_type; /* CONN_UNIX, CONN_INTERNET, or int connect_type; /* CONN_UNIX, CONN_INTERNET, or CONN_IPC */
* CONN_IPC */
#ifdef INTERNET_DOMAIN_SOCKETS #ifdef INTERNET_DOMAIN_SOCKETS
char *hostarg = NULL; /* remote hostname */ char thishost [HOSTNAMSZ]; /* this hostname */
char thishost[HOSTNAMSZ]; /* this hostname */
char remotepath[MAXPATHLEN+1]; /* remote pathname */
int rflg = 0; /* pathname given on cmdline */
u_short port = 0; /* port to server */
#endif /* INTERNET_DOMAIN_SOCKETS */ #endif /* INTERNET_DOMAIN_SOCKETS */
#ifdef SYSV_IPC #ifdef SYSV_IPC
struct msgbuf *msgp; /* message */ struct msgbuf *msgp; /* message */
@@ -66,42 +61,12 @@ main (int argc, char *argv[])
glibtop_init (); glibtop_init ();
#ifdef INTERNET_DOMAIN_SOCKETS
memset (remotepath, 0, sizeof (remotepath));
#endif /* INTERNET_DOMAIN_SOCKETS */
#if defined(INTERNET_DOMAIN_SOCKETS)
connect_type = glibtop_make_connection (hostarg, port, &s);
#else
connect_type = glibtop_make_connection (NULL, (u_short) 0, &s); connect_type = glibtop_make_connection (NULL, (u_short) 0, &s);
#endif
#ifdef INTERNET_DOMAIN_SOCKETS #ifdef INTERNET_DOMAIN_SOCKETS
if (connect_type == (int) CONN_INTERNET) if (connect_type == (int) CONN_INTERNET)
{ {
char *ptr;
gethostname (thishost, HOSTNAMSZ); gethostname (thishost, HOSTNAMSZ);
if (!rflg)
{ /* attempt to generate a path
* to this machine */
if ((ptr = getenv ("LIBGTOP_NODE")) != NULL)
/* user specified a path */
strcpy (remotepath, ptr);
}
#if 0 /* This is really bogus... re-enable it if you must have it! */
#if defined (hp9000s300) || defined (hp9000s800)
else if (strcmp (thishost,hostarg))
{ /* try /net/thishost */
strcpy (remotepath, "/net/"); /* (this fails using internet
addresses) */
strcat (remotepath, thishost);
}
#endif
#endif
}
else
{ /* same machines, no need for path */
remotepath[0] = '\0'; /* default is the empty path */
} }
#endif /* INTERNET_DOMAIN_SOCKETS */ #endif /* INTERNET_DOMAIN_SOCKETS */

View File

@@ -25,6 +25,8 @@
#include <glibtop/command.h> #include <glibtop/command.h>
#include <glibtop/xmalloc.h> #include <glibtop/xmalloc.h>
#include <glibtop/gnuserv.h>
/* Opens pipe to gtop server. Returns 0 on success and -1 on error. */ /* Opens pipe to gtop server. Returns 0 on success and -1 on error. */
void void
@@ -35,6 +37,7 @@ glibtop_open_l (glibtop *server, const char *program_name,
char *server_command, *server_rsh, *temp; char *server_command, *server_rsh, *temp;
char *server_host, *server_user; char *server_host, *server_user;
glibtop_sysdeps sysdeps; glibtop_sysdeps sysdeps;
int connect_type;
memset (server, 0, sizeof (glibtop)); memset (server, 0, sizeof (glibtop));
@@ -43,6 +46,23 @@ glibtop_open_l (glibtop *server, const char *program_name,
/* Is the user allowed to override the server ? */ /* Is the user allowed to override the server ? */
if ((flags & GLIBTOP_OPEN_NO_OVERRIDE) == 0) { if ((flags & GLIBTOP_OPEN_NO_OVERRIDE) == 0) {
connect_type = glibtop_make_connection
(NULL, (u_short) 0, &server->socket);
#ifdef INTERNET_DOMAIN_SOCKETS
if (connect_type == (int) CONN_INTERNET) {
fprintf (stderr, "Calling GLITOP_CMND_SYSDEPS ...\n");
glibtop_call_l (server, GLIBTOP_CMND_SYSDEPS, 0, NULL,
sizeof (glibtop_sysdeps), &sysdeps);
server->features = sysdeps.features;
fprintf (stderr, "Features: %lu\n", server->features);
return;
}
#endif /* INTERNET_DOMAIN_SOCKETS */
/* Try to get data from environment. */ /* Try to get data from environment. */

View File

@@ -27,15 +27,36 @@ void
glibtop_read_l (glibtop *server, size_t size, void *buf) glibtop_read_l (glibtop *server, size_t size, void *buf)
{ {
size_t ssize; size_t ssize;
int ret;
glibtop_init_r (&server, 0, 0); glibtop_init_r (&server, 0, 0);
if (read (server->input [0], &ssize, sizeof (size_t)) < 0) #ifdef DEBUG
glibtop_error_r (server, _("read size: %s"), strerror (errno)); fprintf (stderr, "LIBRARY: reading %d bytes, should be %d.\n", sizeof (size_t), size);
#endif
if (server->socket) {
ret = recv (server->socket, &ssize, sizeof (size_t), 0);
} else {
ret = read (server->input [0], &ssize, sizeof (size_t));
}
if (ret < 0)
glibtop_error_io_r (server, _("read size"));
if (size != ssize) if (size != ssize)
glibtop_error_r (server, _("got %d bytes but requested %d"), ssize, size); glibtop_error_r (server, _("got %d bytes but requested %d (ret = %d)"), ssize, size, ret);
if (read (server->input [0], buf, size) < 0) #ifdef DEBUG
glibtop_error_r (server, _("read %d bytes: %s"), size, strerror (errno)); fprintf (stderr, "LIBRARY: really reading %d bytes.\n", size);
#endif
if (server->socket) {
ret = recv (server->socket, buf, size, 0);
} else {
ret = read (server->input [0], buf, size);
}
if (ret < 0)
glibtop_error_io_r (server, _("read %d bytes"), size);
} }

View File

@@ -29,20 +29,39 @@ glibtop_read_data_l (glibtop *server)
{ {
size_t size; size_t size;
void *ptr; void *ptr;
int ret;
glibtop_init_r (&server, 0, 0); glibtop_init_r (&server, 0, 0);
if (read (server->input [0], &size, sizeof (size_t)) < 0) #ifdef DEBUG
glibtop_error_r (server, _("read data size: %s"), fprintf (stderr, "LIBRARY: reading %d data bytes.\n", sizeof (size_t));
strerror (errno)); #endif
if (server->socket) {
ret = recv (server->socket, &size, sizeof (size_t), 0);
} else {
ret = read (server->input [0], &size, sizeof (size_t));
}
if (ret < 0)
glibtop_error_io_r (server, _("read data size"));
#ifdef DEBUG
fprintf (stderr, "LIBRARY: really reading %d data bytes (ret = %d).\n", size, ret);
#endif
if (!size) return NULL; if (!size) return NULL;
ptr = glibtop_malloc_r (server, size); ptr = glibtop_malloc_r (server, size);
if (read (server->input [0], ptr, size) < 0) if (server->socket) {
glibtop_error_r (server, _("read data %d bytes: %s"), ret = recv (server->socket, ptr, size, 0);
size, strerror (errno)); } else {
ret = read (server->input [0], ptr, size);
}
if (ret < 0)
glibtop_error_io_r (server, _("read data %d bytes"));
return ptr; return ptr;
} }

View File

@@ -26,13 +26,35 @@
void void
glibtop_write_l (glibtop *server, size_t size, void *buf) glibtop_write_l (glibtop *server, size_t size, void *buf)
{ {
int ret;
glibtop_init_r (&server, 0, 0); glibtop_init_r (&server, 0, 0);
if (write (server->output [1], &size, sizeof (size_t)) < 0) #ifdef DEBUG
glibtop_error_r (server, _("write size: %s"), strerror (errno)); fprintf (stderr, "LIBRARY: writing %d bytes = %d.\n", sizeof (size_t), size);
#endif
if (server->socket) {
ret = send (server->socket, &size, sizeof (size_t), 0);
} else {
ret = write (server->output [1], &size, sizeof (size_t));
}
if (ret < 0)
glibtop_error_io_r (server, _("write size"));
if (!size) return; if (!size) return;
if (write (server->output [1], buf, size) < 0) #ifdef DEBUG
glibtop_error_r (server, _("write %d bytes: %s"), size, strerror (errno)); fprintf (stderr, "LIBRARY: really writing %d bytes.\n", size);
#endif
if (server->socket) {
ret = send (server->socket, buf, size, 0);
} else {
ret = write (server->output [1], buf, size);
}
if (ret < 0)
glibtop_error_io_r (server, _("write %d bytes"), size);
} }

25
src/daemon/Makefile.am Normal file
View File

@@ -0,0 +1,25 @@
LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@
INCLUDES = -I$(top_builddir) -I$(top_srcdir) @machine_incs@ \
-I$(top_srcdir)/include -I$(top_srcdir)/intl @GUILE_INCS@ \
-DGTOPLOCALEDIR=\"$(datadir)/locale\" -D_GNU_SOURCE
CFLAGS = -Wall -W @CFLAGS@ -DGTOP_SERVER=\""@LIBGTOP_SERVER@"\"
bin_PROGRAMS = gnuserv
EXTRA_PROGRAMS = gtop_daemon
gnuserv_SOURCES = gnuserv.c main.c
gnuserv_LDADD = $(top_builddir)/lib/libgtop.la \
$(top_builddir)/sysdeps/common/libgtop_common.la \
$(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \
@INTLLIBS@ @LIBSUPPORT@ @X_LIBS@ -lXau
gnuserv_LDFLAGS = -static
gtop_daemon_SOURCES = main.c inet.c loop.c output.c version.c
gtop_daemon_LDADD = $(top_builddir)/lib/libgtop.la \
$(top_builddir)/sysdeps/common/libgtop_common.la \
$(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \
@INTLLIBS@ @LIBSUPPORT@
gtop_daemon_LDFLAGS = -static

View File

@@ -33,12 +33,17 @@
static char rcsid [] = "!Header: gnuserv.c,v 2.1 95/02/16 11:58:27 arup alpha !"; static char rcsid [] = "!Header: gnuserv.c,v 2.1 95/02/16 11:58:27 arup alpha !";
#endif #endif
#define DEBUG
#include <glibtop/gnuserv.h> #include <glibtop/gnuserv.h>
#include <glibtop/open.h>
#ifdef AIX #ifdef AIX
#include <sys/select.h> #include <sys/select.h>
#endif #endif
extern void handle_socket_connection __P((int));
#if !defined(SYSV_IPC) && !defined(UNIX_DOMAIN_SOCKETS) && !defined(INTERNET_DOMAIN_SOCKETS) #if !defined(SYSV_IPC) && !defined(UNIX_DOMAIN_SOCKETS) && !defined(INTERNET_DOMAIN_SOCKETS)
main () main ()
{ {
@@ -417,6 +422,10 @@ permitted (u_long host_addr, int fd)
if (timed_read(fd, auth_protocol, AUTH_NAMESZ, AUTH_TIMEOUT, 1) <= 0) if (timed_read(fd, auth_protocol, AUTH_NAMESZ, AUTH_TIMEOUT, 1) <= 0)
return FALSE; return FALSE;
#ifdef DEBUG
fprintf (stderr, "Client sent authenticatin protocol '%s'\n", auth_protocol);
#endif
if (strcmp (auth_protocol, DEFAUTH_NAME) && if (strcmp (auth_protocol, DEFAUTH_NAME) &&
strcmp (auth_protocol, MCOOKIE_NAME)) strcmp (auth_protocol, MCOOKIE_NAME))
{ {
@@ -425,24 +434,24 @@ permitted (u_long host_addr, int fd)
return FALSE; return FALSE;
} }
if (!strcmp(auth_protocol, MCOOKIE_NAME)) if (!strcmp (auth_protocol, MCOOKIE_NAME))
{ {
/* /*
* doing magic cookie auth * doing magic cookie auth
*/ */
if (timed_read(fd, buf, 10, AUTH_TIMEOUT, 1) <= 0) if (timed_read (fd, buf, 10, AUTH_TIMEOUT, 1) <= 0)
return FALSE; return FALSE;
auth_data_len = atoi(buf); auth_data_len = atoi (buf);
if (timed_read(fd, buf, auth_data_len, AUTH_TIMEOUT, 0) != auth_data_len) if (timed_read (fd, buf, auth_data_len, AUTH_TIMEOUT, 0) != auth_data_len)
return FALSE; return FALSE;
#ifdef AUTH_MAGIC_COOKIE #ifdef AUTH_MAGIC_COOKIE
if (server_xauth && server_xauth->data && if (server_xauth && server_xauth->data &&
!memcmp(buf, server_xauth->data, auth_data_len)) !memcmp (buf, server_xauth->data, auth_data_len))
{ {
return TRUE; return TRUE;
} }
@@ -471,10 +480,18 @@ permitted (u_long host_addr, int fd)
/* First find the hash key */ /* First find the hash key */
key = HASH(host_addr) % TABLE_SIZE; key = HASH(host_addr) % TABLE_SIZE;
#ifdef DEBUG
fprintf (stderr, "Doing GNU_SECURE auth ...\n");
#endif
/* Now check the chain for that hash key */ /* Now check the chain for that hash key */
for(entry = permitted_hosts[key]; entry != NULL; entry=entry->next) for(entry = permitted_hosts [key]; entry != NULL; entry = entry->next) {
#ifdef DEBUG
fprintf (stderr, "Trying %ld\n", entry->host_addr);
#endif
if (host_addr == entry->host_addr) if (host_addr == entry->host_addr)
return(TRUE); return(TRUE);
}
return(FALSE); return(FALSE);
@@ -625,20 +642,34 @@ handle_internet_request (int ls)
size_t addrlen = sizeof(struct sockaddr_in); size_t addrlen = sizeof(struct sockaddr_in);
struct sockaddr_in peer; /* for peer socket address */ struct sockaddr_in peer; /* for peer socket address */
memset((char *)&peer,0,sizeof(struct sockaddr_in)); memset((char *)&peer, 0, sizeof (struct sockaddr_in));
if ((s = accept(ls,(struct sockaddr *)&peer, (void *) &addrlen)) == -1) if ((s = accept (ls, (struct sockaddr *)&peer, (void *) &addrlen)) == -1)
glibtop_error_io ("accept"); glibtop_error_io ("accept");
#ifdef DEBUG
fprintf (stderr, "Connection was made from %s.\n", inet_ntoa (peer.sin_addr));
#endif
/* Check that access is allowed - if not return crud to the client */ /* Check that access is allowed - if not return crud to the client */
if (!permitted(peer.sin_addr.s_addr, s)) if (!permitted (peer.sin_addr.s_addr, s))
{ {
close(s); close(s);
glibtop_warn ("Refused connection from %s", inet_ntoa (peer.sin_addr)); glibtop_warn ("Refused connection from %s.", inet_ntoa (peer.sin_addr));
return; return;
} /* if */ } /* if */
echo_request(s); #ifdef DEBUG
fprintf (stderr, "Accepted connection from %s.\n", inet_ntoa (peer.sin_addr));
#endif
handle_socket_connection (s);
close (s);
#ifdef DEBUG
fprintf (stderr, "Closed connection to %s.\n", inet_ntoa (peer.sin_addr));
#endif
} /* handle_internet_request */ } /* handle_internet_request */
#endif /* INTERNET_DOMAIN_SOCKETS */ #endif /* INTERNET_DOMAIN_SOCKETS */
@@ -746,7 +777,7 @@ main(argc,argv)
struct msgbuf *msgp; /* message buffer */ struct msgbuf *msgp; /* message buffer */
#endif /* SYSV_IPC */ #endif /* SYSV_IPC */
glibtop_init (); glibtop_init_r (&glibtop_global_server, 0, GLIBTOP_OPEN_NO_OVERRIDE);
for(chan=3; chan < _NFILE; close(chan++)) /* close unwanted channels */ for(chan=3; chan < _NFILE; close(chan++)) /* close unwanted channels */
; ;
@@ -775,6 +806,10 @@ main(argc,argv)
if (ils >= 0) if (ils >= 0)
FD_SET(ils, &rmask); FD_SET(ils, &rmask);
#ifdef DEBUG
fprintf (stderr, "Server ready and waiting for connections.\n");
#endif
if (select(max2(fileno(stdin),max2(uls,ils)) + 1, &rmask, if (select(max2(fileno(stdin),max2(uls,ils)) + 1, &rmask,
(fd_set *)NULL, (fd_set *)NULL, (struct timeval *)NULL) < 0) (fd_set *)NULL, (fd_set *)NULL, (struct timeval *)NULL) < 0)
glibtop_error_io ("select"); glibtop_error_io ("select");

259
src/daemon/main.c Normal file
View File

@@ -0,0 +1,259 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <glibtop/gnuserv.h>
#include <glibtop/command.h>
#include <glibtop/version.h>
#include <glibtop/xmalloc.h>
#include <glibtop/union.h>
#include <glibtop/open.h>
#include <fcntl.h>
#include <locale.h>
#if defined(HAVE_GETDTABLESIZE)
#define GET_MAX_FDS() getdtablesize()
#else
/* Fallthrough case - please add other #elif cases above
for different OS's as necessary */
#define GET_MAX_FDS() 256
#endif
static void
do_output (int s, size_t size, const void *buf)
{
#ifdef REAL_DEBUG
fprintf (stderr, "Writing %d bytes = %d.\n", sizeof (size_t), size);
#endif
if (send (s, &size, sizeof (size_t), 0) < 0)
glibtop_warn_io ("send");
if (!size)
return;
#ifdef REAL_DEBUG
fprintf (stderr, "Really writing %d bytes.\n", size);
#endif
if (send (s, buf, size, 0) < 0)
glibtop_warn_io ("send");
}
void
handle_socket_connection (int s)
{
pid_t pid;
int nread;
size_t size, dsize;
char parameter [BUFSIZ];
struct timeval tv;
glibtop_union data;
glibtop_command cmnd;
glibtop_sysdeps sysdeps;
glibtop server;
void *ptr;
tv.tv_sec = 5;
tv.tv_usec = 0;
while(1) {
nread = recv (s, &size, sizeof (size_t), 0);
if (nread < 0) {
glibtop_warn_io ("recv");
return;
}
if (nread == 0)
return;
if (nread != sizeof (size_t)) {
glibtop_warn ("Expected %d bytes but got %d", sizeof (size_t), nread);
return;
}
if (size != sizeof (glibtop_command)) {
glibtop_warn ("Expected %d bytes but got %d", sizeof (size_t), nread);
return;
}
nread = recv (s, &cmnd, size, 0);
if (nread < 0) {
glibtop_warn_io ("recv");
return;
}
if (nread == 0)
return;
#ifdef REAL_DEBUG
fprintf (stderr, "Received command %d from client.\n", cmnd.command);
#endif
nread = recv (s, &dsize, sizeof (size_t), 0);
/* will return 0 if parent exits. */
if (nread < 0) {
glibtop_warn_io ("recv");
return;
}
if (nread == 0)
return;
if (dsize >= BUFSIZ) {
glibtop_warn ("Client sent %d bytes, but buffer is %d", dsize, BUFSIZ);
return;
}
memset (parameter, 0, sizeof (parameter));
if (dsize) {
#ifdef REAL_DEBUG
fprintf (stderr, "Client has %d bytes of data.\n", dsize);
#endif
nread = recv (s, parameter, dsize, 0);
/* will return 0 if parent exits. */
if (nread < 0) {
glibtop_warn_io ("recv");
return;
}
if (nread == 0)
return;
if (nread != (int) dsize) {
glibtop_warn ("Expected %d bytes but got %d", dsize, nread);
return;
}
}
switch (cmnd.command) {
case GLIBTOP_CMND_SYSDEPS:
sysdeps.features = GLIBTOP_SYSDEPS_ALL;
do_output (s, sizeof (glibtop_sysdeps), &sysdeps);
do_output (s, 0, NULL);
break;
case GLIBTOP_CMND_CPU:
glibtop_get_cpu_l (&server, &data.cpu);
do_output (s, sizeof (glibtop_cpu), &data.cpu);
do_output (s, 0, NULL);
break;
case GLIBTOP_CMND_MEM:
glibtop_get_mem_l (&server, &data.mem);
do_output (s, sizeof (glibtop_mem), &data.mem);
do_output (s, 0, NULL);
break;
case GLIBTOP_CMND_SWAP:
glibtop_get_swap_l (&server, &data.swap);
do_output (s, sizeof (glibtop_swap), &data.swap);
do_output (s, 0, NULL);
break;
case GLIBTOP_CMND_UPTIME:
glibtop_get_uptime_l (&server, &data.uptime);
do_output (s, sizeof (glibtop_uptime), &data.uptime);
do_output (s, 0, NULL);
break;
case GLIBTOP_CMND_LOADAVG:
glibtop_get_loadavg_l (&server, &data.loadavg);
do_output (s, sizeof (glibtop_loadavg), &data.loadavg);
do_output (s, 0, NULL);
break;
case GLIBTOP_CMND_SHM_LIMITS:
glibtop_get_shm_limits_l (&server, &data.shm_limits);
do_output (s, sizeof (glibtop_shm_limits), &data.shm_limits);
do_output (s, 0, NULL);
break;
case GLIBTOP_CMND_MSG_LIMITS:
glibtop_get_msg_limits_l (&server, &data.msg_limits);
do_output (s, sizeof (glibtop_msg_limits), &data.msg_limits);
do_output (s, 0, NULL);
break;
case GLIBTOP_CMND_SEM_LIMITS:
glibtop_get_sem_limits_l (&server, &data.sem_limits);
do_output (s, sizeof (glibtop_sem_limits), &data.sem_limits);
do_output (s, 0, NULL);
break;
case GLIBTOP_CMND_PROCLIST:
ptr = glibtop_get_proclist_l (&server, &data.proclist);
do_output (s, sizeof (glibtop_proclist), &data.proclist);
do_output (s, data.proclist.total, ptr);
glibtop_free_r (&server, ptr);
break;
case GLIBTOP_CMND_PROC_STATE:
memcpy (&pid, parameter, sizeof (pid_t));
glibtop_get_proc_state_l
(&server, &data.proc_state, pid);
do_output (s, sizeof (glibtop_proc_state), &data.proc_state);
do_output (s, 0, NULL);
break;
case GLIBTOP_CMND_PROC_UID:
memcpy (&pid, parameter, sizeof (pid_t));
glibtop_get_proc_uid_l
(&server, &data.proc_uid, pid);
do_output (s, sizeof (glibtop_proc_uid), &data.proc_uid);
do_output (s, 0, NULL);
break;
case GLIBTOP_CMND_PROC_MEM:
memcpy (&pid, parameter, sizeof (pid_t));
glibtop_get_proc_mem_l
(&server, &data.proc_mem, pid);
do_output (s, sizeof (glibtop_proc_mem), &data.proc_mem);
do_output (s, 0, NULL);
break;
case GLIBTOP_CMND_PROC_TIME:
memcpy (&pid, parameter, sizeof (pid_t));
glibtop_get_proc_time_l
(&server, &data.proc_time, pid);
do_output (s, sizeof (glibtop_proc_time), &data.proc_time);
do_output (s, 0, NULL);
break;
case GLIBTOP_CMND_PROC_SIGNAL:
memcpy (&pid, parameter, sizeof (pid_t));
glibtop_get_proc_signal_l
(&server, &data.proc_signal, pid);
do_output (s, sizeof (glibtop_proc_signal), &data.proc_signal);
do_output (s, 0, NULL);
break;
case GLIBTOP_CMND_PROC_KERNEL:
memcpy (&pid, parameter, sizeof (pid_t));
glibtop_get_proc_kernel_l
(&server, &data.proc_kernel, pid);
do_output (s, sizeof (glibtop_proc_kernel), &data.proc_kernel);
do_output (s, 0, NULL);
break;
case GLIBTOP_CMND_PROC_SEGMENT:
memcpy (&pid, parameter, sizeof (pid_t));
glibtop_get_proc_segment_l
(&server, &data.proc_segment, pid);
do_output (s, sizeof (glibtop_proc_segment), &data.proc_segment);
do_output (s, 0, NULL);
break;
}
}
}

View File

@@ -12,5 +12,5 @@ gtop_proxy_SOURCES = main.c output.c version.c
gtop_proxy_LDADD = $(top_builddir)/lib/libgtop.la \ gtop_proxy_LDADD = $(top_builddir)/lib/libgtop.la \
$(top_builddir)/sysdeps/common/libgtop_common.la \ $(top_builddir)/sysdeps/common/libgtop_common.la \
$(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \ $(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \
@INTLLIBS@ @LIBSUPPORT@ @INTLLIBS@ @LIBSUPPORT@ @libs_xauth@
gtop_proxy_LDFLAGS = -static gtop_proxy_LDFLAGS = -static