home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / unix / bsd / 10510 < prev    next >
Encoding:
Internet Message Format  |  1992-12-21  |  2.2 KB

  1. Path: sparky!uunet!pipex!bnr.co.uk!uknet!axion!rtf.bt.co.uk!duplain
  2. From: duplain@rtf.bt.co.uk (Andy Duplain)
  3. Newsgroups: comp.unix.bsd
  4. Subject: Patch to allow ps(1) to identify console-controlled processes
  5. Message-ID: <1992Dec21.154652.28356@rtf.bt.co.uk>
  6. Date: 21 Dec 92 15:46:52 GMT
  7. Organization: BT Customer Systems, Brighton, UK
  8. Lines: 61
  9.  
  10.  
  11.     Hi, here is a hack to allow ps(1) to see processes that have the
  12.     console as there controlling tty.  I don't understand why there
  13.     is both a console and a PC console device, but basically all
  14.     processes that are controlled from the console have the major device
  15.     number of 12, while /dev/console has a major device number of 0.  An
  16.     alternative solution _could_ be to add a filesystem node for the
  17.     PC console device and then run dev_mkdb(8) again (having changed the
  18.     definition of _PATH_CONSOLE from /dev/console to /dev/whatever).
  19.  
  20.     I don't have X running so these things may have been patched properly
  21.     by someone else...
  22.  
  23.     Apply these patches at your own risk --  THEY CERTAINLY ARE A HACK!
  24.  
  25. *** ps.c.ORIG    Mon Dec 21 15:23:58 1992
  26. --- ps.c    Mon Dec 21 15:33:45 1992
  27. ***************
  28. *** 195,203 ****
  29.               struct stat stbuf;
  30.               char pathbuf[MAXPATHLEN];
  31.   
  32. !             if (strcmp(optarg, "co") == 0)
  33. !                 ttypath = _PATH_CONSOLE;
  34. !             else if (*optarg != '/')
  35.                   (void) sprintf(ttypath = pathbuf, "%s%s",
  36.                       _PATH_TTY, optarg);
  37.               else
  38. --- 195,204 ----
  39.               struct stat stbuf;
  40.               char pathbuf[MAXPATHLEN];
  41.   
  42. !             if (strcmp(optarg, "co") == 0) {
  43. !                 ttydev = 0x0c00;    /* HACK!!! */
  44. !                 break;
  45. !             } else if (*optarg != '/')
  46.                   (void) sprintf(ttypath = pathbuf, "%s%s",
  47.                       _PATH_TTY, optarg);
  48.               else
  49. *** devname.c.ORIG    Mon Dec 21 15:09:00 1992
  50. --- devname.c    Mon Dec 21 15:27:04 1992
  51. ***************
  52. *** 54,59 ****
  53. --- 54,65 ----
  54.       static int failure;
  55.       DBT data, key;
  56.   
  57. +     /* hack to allow processes with the PC console device as there
  58. +        controlling tty to be seen -- duplain@btcs.bt.co.uk */
  59. +     if (major(dev) == 12)
  60. +         return ("co");
  61.       if (!db && !failure &&
  62.           !(db = hash_open(_PATH_DEVDB, O_RDONLY, 0, NULL))) {
  63.           (void)fprintf(stderr,
  64.  
  65.  
  66. -- 
  67. Andy Duplain, BT Customer Systems, Brighton, UK.           duplain@rtf.bt.co.uk
  68. #define    DISCLAIMER      My views and opinions are my own, and not my company's
  69.