It might make sense not to use pid files here but to actually test whether the socket /var/guix/daemon-socket/socket works. No idea how to do that with just bash. It would be easy in Python. Committed v4 to guix master as commits 73fbe04107d38f4561636c74d28d7a4935cbb1ef and fe60ef998f537e0e71bbb3377d5886ad297821d0.