sub-process: refactor handshake to common function