An exhaust pipe must be carefully designed to carry toxic and/or noxious fumes away from the users of the machine. Indoor generators and furnaces can quickly fill an enclosed space with carbon monoxide or other poisonous exhaust if they are not properly vented to the outdoors. Also, the exhaust gases from most types of machine are very hot; the pipe itself must be heat-resistant, and it must not pass through or near any combustible materials.
In a two-stroke engine, such as that used on dirt bikes, a bulge in the exhaust pipe known as an expansion chamber uses the pressure of the exhaust to create a pump that squeezes more air and fuel into the cylinder during the intake stroke. This provides greater power and fuel efficiency. 
A chimney serves a similar function in a stationary structure.