No longer use `glibtop_machine.h' for Linux.

1998-07-03  Martin baulig  <martin@home-of-linux.org>

	* macros/gnome-libgtop-sysdeps.m4: No longer use
	`glibtop_machine.h' for Linux.

	* sysdeps/linux/glibtop_machine.h: Removed.

	* sysdeps/guile/guile.awk: Using `scm_append'
	instead of `gh_append'.

	* sysdeps/guile/names/guile-names.awk: dito.

	* sysdeps/linux/*.c: Using code from stable branch again.

	* include/glibtop/parameter.h: New file.

	* lib/parameter.c: New file.

	* lib/{open, init}.c: Done some more work on server
	initialization
This commit is contained in:
Martin baulig
1998-07-03 17:19:25 +00:00
committed by Martin Baulig
parent 94715ef718
commit 9532dadc2e
26 changed files with 557 additions and 355 deletions

View File

@@ -38,8 +38,9 @@ static const unsigned long _glibtop_sysdeps_proc_uid =
void
glibtop_get_proc_uid_s (glibtop *server, glibtop_proc_uid *buf, pid_t pid)
{
char buffer [BUFSIZ], input [BUFSIZ], *tmp;
int fd = 0, nread;
char input [BUFSIZ], *tmp;
int nread;
FILE *f;
glibtop_init_r (&server, 0, 0);
@@ -52,23 +53,22 @@ glibtop_get_proc_uid_s (glibtop *server, glibtop_proc_uid *buf, pid_t pid)
}
sprintf (input, "/proc/%d/status", pid);
fd = open (input, O_RDONLY);
if (fd == -1)
glibtop_error_r (server, "open (%s): %s",
input, strerror (errno));
nread = read (fd, buffer, BUFSIZ);
if (nread == -1)
glibtop_error_r (server, "read (%s): %s",
input, strerror (errno));
buffer [nread] = 0;
close (fd);
f = fopen (input, "r");
if (!f) return;
nread = fread (input, 1, BUFSIZ, f);
if (nread < 0) {
fclose (f);
return;
}
input [nread] = 0;
/* Search substring 'Pid:' */
tmp = strstr (buffer, "Pid:");
tmp = strstr (input, "Pid:");
if (tmp == NULL) return;
@@ -76,25 +76,26 @@ glibtop_get_proc_uid_s (glibtop *server, glibtop_proc_uid *buf, pid_t pid)
"Gid: %u %u %*u %*u\n", &buf->pid, &buf->ppid,
&buf->uid, &buf->euid, &buf->gid, &buf->egid);
fclose (f);
sprintf (input, "/proc/%d/stat", pid);
fd = open (input, O_RDONLY);
if (fd == -1)
glibtop_error_r (server, "open (%s): %s",
input, strerror (errno));
nread = read (fd, buffer, BUFSIZ);
if (nread == -1)
glibtop_error_r (server, "read (%s): %s",
input, strerror (errno));
buffer [nread] = 0;
close (fd);
f = fopen (input, "r");
if (!f) return;
nread = fread (input, 1, BUFSIZ, f);
if (nread < 0) {
fclose (f);
return;
}
input [nread] = 0;
/* This is from guile-utils/gtop/proc/readproc.c */
/* split into "PID (cmd" and "<rest>" */
tmp = strrchr (buffer, ')');
tmp = strrchr (input, ')');
*tmp = '\0'; /* replace trailing ')' with NUL */
/* parse these two strings separately, skipping the leading "(". */
sscanf(tmp + 2, /* skip space after ')' too */
@@ -116,5 +117,7 @@ glibtop_get_proc_uid_s (glibtop *server, glibtop_proc_uid *buf, pid_t pid)
/* when tty wasn't full devno */
buf->tty = 4*0x100 + buf->tty;
fclose (f);
buf->flags = _glibtop_sysdeps_proc_uid;
}