Extend the "-wait" flag handling to support "wait undefinitely" behavior