Reading the process table, writing to pty's
Anton Rang
rang at cpsin3.cps.msu.edu
Tue Nov 29 01:57:26 AEST 1988
I'm looking for two things. The first is a "good" way to read the
process table--in other words, one that isn't likely to break with
every release of the OS. A little background: I have a program to
kill "idle" (non-CPU using) processes. I have currently hacked around
the code from "ps" to read the proc. table, but it's very ugly. Is
there some nice library out there somewhere? This is on a Sun-3.
The next question is fairly simple. How do I find out what terminal
a process is associated with? What I *really* want is to have a way
to write a warning message ("You will be killed in 10 minutes" for
example) to a process. The implementation of "ps", at least on the
Sun-3 under 3.x, seems to be broken in this regard; "background" jobs
should show up without a terminal, and various processes seem to
attach themselves at random to a terminal ("in.syslog" for example).
Finally, one last question. I would like to find out if there is
anyone logged onto a pseudo-terminal. Actually, what I *really* want
is a way to keep open() from hanging when the terminal located for the
process isn't logged on. Right now I just use fork() before the
open() so that when the process hangs it doesn't stop the bouncer
program from running; it is idle, so eventually bouncer kills its own
subprocesses. This is a real mess though.
So...is there anyone out there with some good ideas about this?
Please E-mail responses, as I don't have time to read this newsgroup
all the time. Thanks in advance. (I may post a summary, so if you
don't want your article or name included in one, let me know.)
Thanks again!
+---------------------------+------------------------+----------------------+
| Anton Rang (grad student) | "VMS Forever!" | "Do worry...be SAD!" |
| Michigan State University | rang at cpswh.cps.msu.edu | |
+---------------------------+------------------------+----------------------+
More information about the Comp.unix.wizards
mailing list