add an optional pid lock to the rack middleware