A daemon represents three things:
1. It is the process of daemonizing a program there is a C function for this called daemon(3).
2. A daemon is a program that runs a service on the system, it is not tied to a terminal and may only write reports to syslog or another logging mechanism. There is SMTP daemons such as sendmail that manage all mail operations, or the inetd superserver which manages a number of services such as chargen and ftp. A daemon orphans itself from the parent process and selects init (process 1) as its parent. Stdin, Stdout and Stderr are reattached to /dev/null. A daemon is in it's own session and is its own process group. Daemons that needed to run as root in order to make use of restricted system calls historically stayed running as root. This has changed in modern implementations where privilege revocation or privilege seperation is used in order to ensure security.
3. BSD's original mascot, looks like a devil and should not be confused with a demon (which is evil). The mascot has horns, holds a trident (or fork) in its hands and has a tail. It wears green sneakers (converse basketball sneakers probably) and is seen in early drawings as chasing a golden orb. FreeBSD uses this mascot extensively. OpenBSD has replaced the daemon mascot with puffy the blowfish. If you look closely on a picture of Puffy though the tail often looks like the silhouette of a daemon's head.
This example checks if port 22 is listening in netstat, and if not, it runs /etc/rc.d/sshd.
#!/bin/bash chk=`netstat -an | grep -c :22` if [ "$chk" = "0" ] then echo "sshd is down, start this mofo..."; /etc/rc.d/sshd restart fi