Low voltage currents applied to the rails cause the signal, via a series of relays (originally) or electronics (more recently) to show a "proceed" aspect. The current flow will be interrupted by the presence of the wheels of a train. Such interruption will cause the signal protecting that section to show a "stop" command. Any other cause of current interruption will also cause a "stop" signal to show. Such a system means that a failure gives a red aspect - a stop signal. The system is sometimes referred to as "fail safe" or "vital". A "proceed" signal will only be displayed if the current does flow. Most European main lines with moderate or heavy traffic are equipped with colour light signals operated automatically or semi-automatically by track circuits.
Track Circuit - Block Unoccupied
This diagram above shows how the track circuit is applied to a section or block of track. A low voltage from a battery is applied to one of the running rails in the block and returned via the other. A relay at the entrance to the section detects the voltage and energises to connect a separate supply to the green lamp of the signal.
Track Circuit - Block Occupied
When a train enters the block (left - click for full size view), the leading wheelset short circuits the current, which causes the relay to de-energise and drop the contact so that the signal lamp supply circuit now activates the red signal lamp. The system is "fail-safe", or "vital" as it is sometimes called, because any break in the circuit will cause a danger signal to be displayed.
The above is a simplified description of the track circuit. The reality is somewhat more complex. A block section is normally separated electrically from its neighbouring sections by insulated joints in the rails. However, more recent installations use electronics to allow jointless track circuits. Also, some areas have additional circuits which allow the signals to be manually held at red from a signal box or control centre, even if the section is clear. These are known as semi-automatic signals. Even more complexity is required at junctions.