home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.sgi.bugs
- Path: sparky!uunet!psinntp!pixar!brighton
- From: brighton@pixar.com (Bill Carson)
- Subject: PIOCPSINFO (proc) always EINVAL
- Message-ID: <1993Jan6.181444.26115@pixar.com>
- Originator: brighton@stimpy
- Keywords: PIOCPSINFO proc debug
- Sender: news@pixar.com (Usenet Newsmaster)
- Nntp-Posting-Host: stimpy.pixar.com
- Organization: Pixar - Pt. Richmond, CA USA
- Date: Wed, 6 Jan 1993 18:14:44 GMT
- Lines: 104
-
- Has anyone had any luck with the PIOCPSINFO ioctl?
- According to the 4.0.5 proc(4) man page:
-
- > void *p;
- > retval = ioctl(fildes, code, p);
- >
- > The argument p is a generic pointer whose type depends on the specific
- > ioctl code. Where not specifically mentioned below, its value should be
- > zero. <sys/procfs.h> contains definitions of ioctl codes and data
- > structures used by the operations.
- > ...
- > PIOCPSINFO
- > This returns miscellaneous process information such as that reported by
- > ps(1). p is a pointer to a prpsinfo structure containing at least the
- > following fields:
- >
- > typedef struct prpsinfo {
- > ...
- > } prpsinfo_t
-
-
- Enclosed is a program that demonstrates the failure of the PIOCPSINFO ioctl.
-
- $ cc -o prps prps.c
- $ prps (uses getpid(), or give a PID as first arg)
- prps: using path: /debug/12850
- prst.pr_pid 12850
- prps: ioctl PIOCPSINFO: Invalid argument
-
- [IRIX stimpy 4.0.5 06151813 IP12]
- [also compiled/tried under 4.0.4 and 4.0.5F]
-
- Any and all insight appreciated. Thanks!
-
- - Bill Carson / brighton@pixar.com
-
- --------------------------------------------------------------------
-
- #include <sys/types.h>
-
- #include <stdio.h>
- #include <errno.h>
- #include <malloc.h>
- #include <string.h>
- #include <fcntl.h>
-
- #include <sys/time.h>
- #include <sys/signal.h>
- #include <sys/fault.h>
- #include <sys/syscall.h>
- #include <sys/procfs.h>
-
- static char *PGM = "prps";
- #define ERR sys_errlist[errno]
-
- main(ac, av)
- char **av;
- {
- FILE *pf;
- int pid, ret, fd;
- char path[1024];
- prstatus_t prst;
- prpsinfo_t prps;
- void *v;
-
- if (ac > 1)
- pid = atoi(av[1]);
- else
- pid = getpid();
-
- sprintf(path, "/debug/%05d", pid);
-
- setbuf(stdout, NULL);
- printf("%s: using path: %s\n", PGM, path);
-
- if ((fd = open(path, O_RDONLY, 0)) < 0) {
- fprintf(stderr, "%s: open \"%s\": %s\n", PGM, path, ERR);
- exit(1);
- }
-
- if ((ret = ioctl(fd, PIOCSTATUS, &prst)) < 0) {
- fprintf(stderr, "%s: ioctl PIOCSTATUS: %s\n", PGM, ERR);
- exit(1);
- }
-
- printf("prst.pr_pid %d\n", prst.pr_pid);
-
- /*
- * no matter what, this always fails with EINVAL
- */
- if ((ret = ioctl(fd, PIOCPSINFO, &prps)) < 0) {
- fprintf(stderr, "%s: ioctl PIOCPSINFO: %s\n", PGM, ERR);
- exit(1);
- }
-
- printf("prps.pr_pid %d\n", prps.pr_pid);
-
- if (close(fd) < 0) {
- fprintf(stderr, "%s: close: %s\n", PGM, ERR);
- exit(1);
- }
-
- exit(0);
- }
-