Return to BSD News archive
Received: by minnie.vk1xwt.ampr.org with NNTP id AA5327 ; Wed, 23 Dec 92 11:01:20 EST Path: sserve!manuel.anu.edu.au!munnari.oz.au!spool.mu.edu!olivea!uunet!pipex!bnr.co.uk!uknet!axion!rtf.bt.co.uk!duplain From: duplain@rtf.bt.co.uk (Andy Duplain) Newsgroups: comp.unix.bsd Subject: Patch to allow ps(1) to identify console-controlled processes Message-ID: <1992Dec21.154652.28356@rtf.bt.co.uk> Date: 21 Dec 92 15:46:52 GMT Organization: BT Customer Systems, Brighton, UK Lines: 61 Hi, here is a hack to allow ps(1) to see processes that have the console as there controlling tty. I don't understand why there is both a console and a PC console device, but basically all processes that are controlled from the console have the major device number of 12, while /dev/console has a major device number of 0. An alternative solution _could_ be to add a filesystem node for the PC console device and then run dev_mkdb(8) again (having changed the definition of _PATH_CONSOLE from /dev/console to /dev/whatever). I don't have X running so these things may have been patched properly by someone else... Apply these patches at your own risk -- THEY CERTAINLY ARE A HACK! *** ps.c.ORIG Mon Dec 21 15:23:58 1992 --- ps.c Mon Dec 21 15:33:45 1992 *************** *** 195,203 **** struct stat stbuf; char pathbuf[MAXPATHLEN]; ! if (strcmp(optarg, "co") == 0) ! ttypath = _PATH_CONSOLE; ! else if (*optarg != '/') (void) sprintf(ttypath = pathbuf, "%s%s", _PATH_TTY, optarg); else --- 195,204 ---- struct stat stbuf; char pathbuf[MAXPATHLEN]; ! if (strcmp(optarg, "co") == 0) { ! ttydev = 0x0c00; /* HACK!!! */ ! break; ! } else if (*optarg != '/') (void) sprintf(ttypath = pathbuf, "%s%s", _PATH_TTY, optarg); else *** devname.c.ORIG Mon Dec 21 15:09:00 1992 --- devname.c Mon Dec 21 15:27:04 1992 *************** *** 54,59 **** --- 54,65 ---- static int failure; DBT data, key; + /* hack to allow processes with the PC console device as there + controlling tty to be seen -- duplain@btcs.bt.co.uk */ + + if (major(dev) == 12) + return ("co"); + if (!db && !failure && !(db = hash_open(_PATH_DEVDB, O_RDONLY, 0, NULL))) { (void)fprintf(stderr, -- Andy Duplain, BT Customer Systems, Brighton, UK. duplain@rtf.bt.co.uk #define DISCLAIMER My views and opinions are my own, and not my company's