The pulseIn routine does that for you.
It checks and waits for an already started pulse to finish before starting to measure.The source code is in wiring_pulse.c if you want to see how it does it.
That's true, I didn't know that! Thanks.
But there's something I couldn't figure out: the pulseIn() function expects three arguments--the digital pin #, the state, and the timeout.
What happens if you don't specify the timeout value? What value does pulseIn() assume it to be?