[comp.lang.c] deamon help

gpitcher@edpmgt.UUCP (Glenn Pitcher) (02/05/91)

I have just been given the assignment of writting a deamon that would monitor
a list of programs for inactivity and after a certain amount of inactive time,
send a signal to the process.  The process would then do a gracefull shutdown.

One requirement is that this program must work under SysV and BSD (SunOS).  

Can anyone point me in the right direction?

Thanks in advance.  

-- 
Glenn Pitcher                              UUCP: {crash,ucsd}!edpmgt!gpitcher
Programmer/Analyst &                                  hp-sdd!teamnet!gpitcher
Unix Guru in training                  INTERNET: gpitcher@edpmgt.cts.com
EDP Management, Inc.                         * Proud member of Team.Net *
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

bzs@world.std.com (Barry Shein) (02/05/91)

>I have just been given the assignment of writting a deamon that would monitor
>a list of programs for inactivity and after a certain amount of inactive time,
>send a signal to the process.  The process would then do a gracefull shutdown.
>
>One requirement is that this program must work under SysV and BSD (SunOS).  

Just write a shell script loop which uses awk to suck out the TIME
field of the procs as reported by ps and see if it's changing or not.
The only problem is that the command-line flags are gratuitously
different for ps on SYSV and BSD (tho Sun/OS must have the SYSV clone
version.) You could probably do some test to just change the flags
fields.

For a problem like this I'll bet you a nickel crafting the whole thing
in C using /dev/kmem etc will not be much faster than the above
described script, and will take a week to get right instead of 30
minutes.

(hmm, just checked, Sun/OS doesn't seem to have a SYSV clone ps,
probably for the same reason people don't serve cooking wine at their
dinner table.)
-- 
        -Barry Shein

Software Tool & Die    | bzs@world.std.com          | uunet!world!bzs
Purveyors to the Trade | Voice: 617-739-0202        | Login: 617-739-WRLD

gpitcher@edpmgt.UUCP (Glenn Pitcher) (02/06/91)

In article <594@edpmgt.UUCP> gpitcher@edpmgt.UUCP (Glenn Pitcher) writes:
>I have just been given the assignment of writting a deamon that would monitor
>a list of programs for inactivity and after a certain amount of inactive time,
>send a signal to the process.  The process would then do a gracefull shutdown.

Just as a followup to this, I found out how to access the process table in
SunOS last night via the kvm_* calls and now I need to find equivalent
functions under SysV 3.2 (BTW, this SysV I'm working on is on a Unisys
U6000).


-- 
Glenn Pitcher                              UUCP: {crash,ucsd}!edpmgt!gpitcher
Programmer/Analyst &                                  hp-sdd!teamnet!gpitcher
Unix Guru in training                  INTERNET: gpitcher@edpmgt.cts.com
EDP Management, Inc.                         * Proud member of Team.Net *
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-