diff options
author | Martin Baulig <martin@src.gnome.org> | 1998-08-08 20:04:43 +0000 |
---|---|---|
committer | Martin Baulig <martin@src.gnome.org> | 1998-08-08 20:04:43 +0000 |
commit | c0641998cfee6799b80345693e4a9bc977bd0a5e (patch) | |
tree | 569f0d11f8d3567e4216100ecab0625e2bd33c7a | |
parent | 9cf583b2fae9e0095a850265daffbf1672519754 (diff) | |
download | libgtop-c0641998cfee6799b80345693e4a9bc977bd0a5e.tar.gz |
Minor server/daemon cleanups; reading sysdeps from server now working.
-rw-r--r-- | include/glibtop/open.h | 1 | ||||
-rw-r--r-- | lib/open.c | 2 | ||||
-rw-r--r-- | src/daemon/Makefile.am | 4 | ||||
-rw-r--r-- | src/daemon/main.c | 4 | ||||
-rw-r--r-- | src/daemon/server.c | 15 | ||||
-rw-r--r-- | src/daemon/slave.c | 6 |
6 files changed, 15 insertions, 17 deletions
diff --git a/include/glibtop/open.h b/include/glibtop/open.h index 4c8fdf15..0e0248fa 100644 --- a/include/glibtop/open.h +++ b/include/glibtop/open.h @@ -51,6 +51,7 @@ __BEGIN_DECLS extern void glibtop_open_l __P((glibtop *, const char *, const unsigned long, const unsigned)); +extern void glibtop_init_p __P((glibtop *, const unsigned long, const unsigned)); extern void glibtop_open_p __P((glibtop *, const char *, const unsigned long, const unsigned)); extern void glibtop_open_s __P((glibtop *, const char *, const unsigned long, const unsigned)); @@ -176,6 +176,8 @@ glibtop_open_l (glibtop *server, const char *program_name, server->features = sysdeps.features; + memcpy (&server->sysdeps, &sysdeps, sizeof (glibtop_sysdeps)); + fprintf (stderr, "Server features are %lu.\n", server->features); } diff --git a/src/daemon/Makefile.am b/src/daemon/Makefile.am index 4d10814b..7f03c2e8 100644 --- a/src/daemon/Makefile.am +++ b/src/daemon/Makefile.am @@ -1,9 +1,7 @@ LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ CFLAGS = -Wall -W @CFLAGS@ \ - -DDEBUG -DREAL_DEBUG -D_BSD \ - -DPARENT_DEBUG -DSLAVE_DEBUG \ - -DGLIBTOP_DAEMON_SLAVE + -D_BSD -DGLIBTOP_DAEMON_SLAVE if NEED_LIBGTOP suid_sysdeps = $(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps_suid.la diff --git a/src/daemon/main.c b/src/daemon/main.c index 3319a2e9..7b3c4796 100644 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -56,6 +56,8 @@ handle_parent_connection (int s) return; } + memset (resp, 0, sizeof (glibtop_response)); + memset (parameter, 0, sizeof (parameter)); if (cmnd->data_size) { @@ -88,6 +90,8 @@ handle_parent_connection (int s) #endif return; case GLIBTOP_CMND_SYSDEPS: + memcpy (&resp->u.sysdeps, &server->sysdeps, + sizeof (glibtop_sysdeps)); resp->u.sysdeps.features = GLIBTOP_SYSDEPS_ALL; do_output (s, resp, _offset_union (sysdeps), 0, NULL); break; diff --git a/src/daemon/server.c b/src/daemon/server.c index 815a5f0f..c9785423 100644 --- a/src/daemon/server.c +++ b/src/daemon/server.c @@ -49,14 +49,6 @@ GLIBTOP_SUID_PROC_SEGMENT; #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 - int main(int argc, char *argv[]) { @@ -69,7 +61,7 @@ main(int argc, char *argv[]) uid = getuid (); euid = geteuid (); gid = getgid (); egid = getegid (); - glibtop_open_p (glibtop_global_server, argv [0], 0, 0); + glibtop_init_p (glibtop_global_server, 0, 0); if (setreuid (euid, uid)) _exit (1); @@ -77,11 +69,6 @@ main(int argc, char *argv[]) /* !!! END OF SUID ROOT PART !!! */ - /* close all file descriptors except ones used by the pipes (0 and 1). */ - max_fd = GET_MAX_FDS(); - for(fd = 3 /* The first fd after the pipes */; fd < max_fd; fd++) - close(fd); - handle_slave_connection (0, 0); _exit (0); diff --git a/src/daemon/slave.c b/src/daemon/slave.c index ba58b2f1..de41bd74 100644 --- a/src/daemon/slave.c +++ b/src/daemon/slave.c @@ -43,6 +43,8 @@ handle_slave_connection (int input, int output) "but buffer is %d", cmnd->size, BUFSIZ); + memset (resp, 0, sizeof (glibtop_response)); + memset (parameter, 0, sizeof (parameter)); if (cmnd->data_size) { @@ -87,6 +89,10 @@ handle_slave_command (glibtop_command *cmnd, glibtop_response *resp, switch (cmnd->command) { case GLIBTOP_CMND_SYSDEPS: + fprintf (stderr, "SYSDEPS: %p - %lx\n", + server, server->sysdeps.cpu); + memcpy (&resp->u.sysdeps, &server->sysdeps, + sizeof (glibtop_sysdeps)); resp->u.sysdeps.features = glibtop_server_features; resp->offset = _offset_union (sysdeps); break; |