Project 3: A Friendly Daemon

Due Thursday, May 12, by 9:00 AM (Start of the final exam)

On Unix-like systems, including Linux, long-running processes are called daemons (always spelled with the a). The name is a reference to Maxwell's Demon, which in the Wikipedia article, is spelled without an a. Regardless of spelling, quite a few long-running background processes exist on any operating system.

For this assignment, write a daemon which will notice when you log in, as well as message other users when they log in if you have a message for them. The daemon should periodically check to see if you have logged in, and if you have, send you a greeting. Once per minute is a reasonable frequency here, particularly since the command "last" supports minutes well. Note that "once per minute" is the frequency of checking. Only send one message in response to each new login! Otherwise it will be very annoying. In addition to checking for you, the daemon should look at the contents of a directory in your home directory named ".outgoing", which will contain messages for other users. Each file in .outgoing should be the name of another user, and the contents should be a message for that user. If the user is currently logged in, the daemon will send them the contents of the file, and delete the file so the message is not sent again. Specifics you might find useful: I posted my (compiled) solution, called friendly_daemon, in the class examples area. Feel free to play with it. The check frequency is every minute, so when you log in, it might take up to a minute for the daemon to respond.