Checking for new mail (and killing bkgnd process on logout?)

Bruce Walker bmw at isgtec.UUCP
Wed Aug 30 00:40:42 AEST 1989


Since I haven't seen anyone mention it yet, I will:
in the extremely well-written and useful book "The UNIX Programming
Environment" by Kernighan and Pike, there is a small bit of C called
"checkmail" (pg. 216).  To link it you'll also need a code fragment
called "error()" (pg. 207).

This program does what none of the to-date posted ones do: it checks
for the mail file *growing*, not just *changing*; otherwise you'll
get "you have mail" messages after you read your mail (and it is
deleted from your mailbox).

Not mentioned in the book though, is the fact that this program will
not work as advertised on BSD systems.  You are supposed to start it
like this (usually from .login):

	$ checkmail&

which is fine under SysX, since when you log out, it goes away by
itself.  However, if you do this on a Sun (f'rinstance), the process
disconnects from your tty and continues running (inherited by root).
You end up with dozens of the little buggers.

My (slightly klugey) solution is to add a line to my .logout (csh):

	/bin/kill -9 `ps x | awk '$5=="checkmail" {print $1}'`&

Anyone know a better way?
-- 
Bruce Walker                          ...uunet!mnetor!lsuc!isgtec!bmw
"Better Living Through Connectivity"         ...utzoo!lsuc!isgtec!bmw
ISG Technologies Inc. 3030 Orlando Dr. Mississauga. Ont. Can. L4V 1S8



More information about the Comp.unix.xenix mailing list