add waitpid() to prevent spawning multiple children in static mode