home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / sgi / bugs / 81 < prev    next >
Encoding:
Text File  |  1993-01-06  |  2.7 KB  |  118 lines

  1. Newsgroups: comp.sys.sgi.bugs
  2. Path: sparky!uunet!psinntp!pixar!brighton
  3. From: brighton@pixar.com (Bill Carson)
  4. Subject: PIOCPSINFO (proc) always EINVAL
  5. Message-ID: <1993Jan6.181444.26115@pixar.com>
  6. Originator: brighton@stimpy
  7. Keywords: PIOCPSINFO proc debug
  8. Sender: news@pixar.com (Usenet Newsmaster)
  9. Nntp-Posting-Host: stimpy.pixar.com
  10. Organization: Pixar - Pt. Richmond, CA USA
  11. Date: Wed, 6 Jan 1993 18:14:44 GMT
  12. Lines: 104
  13.  
  14. Has anyone had any luck with the PIOCPSINFO ioctl?
  15. According to the 4.0.5 proc(4) man page:
  16.  
  17. >          void *p;
  18. >          retval = ioctl(fildes, code, p);
  19. >
  20. >     The argument p is a generic pointer whose type depends on the specific
  21. >     ioctl code.  Where not specifically mentioned below, its value should be
  22. >     zero.  <sys/procfs.h> contains definitions of ioctl codes and data
  23. >     structures used by the operations.
  24. > ...
  25. >   PIOCPSINFO
  26. >     This returns miscellaneous process information such as that reported by
  27. >     ps(1).  p is a pointer to a prpsinfo structure containing at least the
  28. >     following fields:
  29. >
  30. >     typedef struct prpsinfo {
  31. >    ...
  32. >     } prpsinfo_t
  33.  
  34.  
  35. Enclosed is a program that demonstrates the failure of the PIOCPSINFO ioctl.
  36.  
  37. $ cc -o prps prps.c
  38. $ prps                (uses getpid(), or give a PID as first arg)
  39. prps: using path: /debug/12850
  40. prst.pr_pid 12850
  41. prps: ioctl PIOCPSINFO: Invalid argument
  42.  
  43. [IRIX stimpy 4.0.5 06151813 IP12]
  44. [also compiled/tried under 4.0.4 and 4.0.5F]
  45.  
  46. Any and all insight appreciated.  Thanks!
  47.  
  48. - Bill Carson / brighton@pixar.com
  49.  
  50. --------------------------------------------------------------------
  51.  
  52. #include <sys/types.h>
  53.  
  54. #include <stdio.h>
  55. #include <errno.h>
  56. #include <malloc.h>
  57. #include <string.h>
  58. #include <fcntl.h>
  59.  
  60. #include <sys/time.h>
  61. #include <sys/signal.h>
  62. #include <sys/fault.h>
  63. #include <sys/syscall.h>
  64. #include <sys/procfs.h>
  65.  
  66. static char *PGM = "prps";
  67. #define ERR sys_errlist[errno]
  68.  
  69. main(ac, av)
  70. char **av;
  71. {
  72.     FILE *pf;
  73.     int pid, ret, fd;
  74.     char path[1024];
  75.     prstatus_t prst;
  76.     prpsinfo_t prps;
  77.     void *v;
  78.  
  79.     if (ac > 1)
  80.         pid = atoi(av[1]);
  81.     else
  82.         pid = getpid();
  83.     
  84.     sprintf(path, "/debug/%05d", pid);
  85.  
  86.     setbuf(stdout, NULL);
  87.     printf("%s: using path: %s\n", PGM, path);
  88.  
  89.     if ((fd = open(path, O_RDONLY, 0)) < 0) {
  90.         fprintf(stderr, "%s: open \"%s\": %s\n", PGM, path, ERR);
  91.         exit(1);
  92.     }
  93.  
  94.     if ((ret = ioctl(fd, PIOCSTATUS, &prst)) < 0) {
  95.         fprintf(stderr, "%s: ioctl PIOCSTATUS: %s\n", PGM, ERR);
  96.         exit(1);
  97.     }
  98.  
  99.     printf("prst.pr_pid %d\n", prst.pr_pid);
  100.  
  101.     /*
  102.      * no matter what, this always fails with EINVAL
  103.      */
  104.     if ((ret = ioctl(fd, PIOCPSINFO, &prps)) < 0) {
  105.         fprintf(stderr, "%s: ioctl PIOCPSINFO: %s\n", PGM, ERR);
  106.         exit(1);
  107.     }
  108.  
  109.     printf("prps.pr_pid %d\n", prps.pr_pid);
  110.  
  111.     if (close(fd) < 0) {
  112.         fprintf(stderr, "%s: close: %s\n", PGM, ERR);
  113.         exit(1);
  114.     }
  115.  
  116.     exit(0);
  117. }
  118.