Viral dormancy, in which the infected cell is not killed but rather becomes the long-term residence of the parasite, is a hallmark of viruses across kingdoms, from bacteriophages to HIV. When and how viruses decide to opt for this lifestyle remains mysterious. Phage lambda, which serves as a paradigm for viral dormancy, is reported to count the number of coinfecting viruses and then use this value to assess the abundance of potential hosts and decide whether to become dormant. We use a single-cell measurement of viruses and their expressed genes, together with mathematical modeling, to illuminate how lambda performs this task. I will discuss some of our recent findings and ongoing work.