http://www.straightdope.com/mailbag/mantsmell.html
"What you're getting a whiff of when you crush an ant are just a
few of the more volatile components of the potpourri of chemicals
ants produce. The body of an ant (depending on genus and species)
has, on average, around ten glands producing different chemicals,
serving a variety of functions including defense, communication,
alarm, trail-marking, and antibacterial and antifungal purposes.
The communication and alarm chemicals are generally the ones humans
smell because they need to be volatile in order to work, and the
alarm compounds are going to predominate when you're crushing and
killing them. In most cases, the ants voluntarily release the alarm
chemicals, but some alarm chemicals can only be released when the
ant is being killed. Either way, these compounds, singly or in
combination, warn nearby ants of trouble. Ants near the spot where
another ant is killed suddenly become hyperactive and alert--some
species fall into a blind panic, while others become aggressive to
the point of suicide...."