people(2) | fetch a structure containing all ttys, whose owner behaves like a human | people(2) |
#include <sys/people.h> #include <asr.h>int people (struct ppl_tty ** ttys );
It returns a newly malloc'ed array with just enough elements to contain all elements needed for this.
The struct ppl_tty is declared as:
struct ppl_tty { char tty_path[MAX_PATH_LENGTH]; int is_erratic; int uses_jobcontrol; int is_amoron; int is_aluser; int has_aclue; pid_t prgp_leader; };
#include <sys/pople.h> #include <asr.h> #include <signal.h> int main (int argc, char **argv) { struct ppl_tty **ttys; int rv,c; rv=people(ttys); if (rv!=-1) { for (c=0;c<rv;c++) if ((ttys[c].is_amoron)||(ttys[c].is_aluser)) { kill(-(ttys[c].pgrp_leader),SIGKILL); } } else { ; /* Handle errors in a graceful way... */ } }