So what is in ../../bin/archive_command.ssh_to_slaves.bash? Why are you using "exec"?
we send all the wal files through that script
# we open the file from here
exec {WAL_LOCK_FD}>"${WAL_SEGMENT}.ac_lock" || exit 4; if ! flock -n ${WAL_LOCK_FD}; then printf 'Cannot acquire lock for WAL segment `%s`. Aborting\n' "${WAL_SEGMENT}" 1>&2; exit 4; fi;
# time to connect and send the wal segments to all hosts. We count the failed transfers TRANSFER_ERRORS=0; ARORD=0; # see above for NEXT_PAIR in "${@}"; do if [ $((ARORD++)) -gt 0 ]; then NEXT_HOST="${NEXT_PAIR%:*}"; if [[ "${NEXT_PAIR}" =~ : ]]; then NEXT_PORT=${NEXT_PAIR#*:}; else NEXT_PORT=22; fi; # we use tar over SSH as I don't fully trust scp's exit status. The added benefit is that tar preserves all attributes # the downside is that it's a little tricky to make the remote path relative #printf 'Attempting to archive WAL segment `%s` on host `%s`\n' "${WAL_SEGMENT}" "${NEXT_PAIR}" 1>&2; IFS=':'; set +e; tar -c -O --no-same-owner -C "${WAL_SEGMENT%/*}" "${WAL_SEGMENT##*/}" | ssh -p ${NEXT_PORT} -C -o 'BatchMode=yes' -o 'CompressionLevel=3' "${USER}@${NEXT_HOST}" "exec tar -x --no-same-owner --overwrite -C '${WAL_ARCHIVE_PATH}'"; PS_CONCAT="${PIPESTATUS[*]}"; set -e; IFS="${DEFAULT_IFS}"; if [ "${PS_CONCAT}" == '0:0' ]; then printf 'WAL segment `%s` successfully archived on host `%s`\n' "${WAL_SEGMENT}" "${NEXT_PAIR}" 1>&2; else : $((TRANSFER_ERRORS++)); printf 'Failed to archive WAL segment `%s` on host `%s`\n' "${WAL_SEGMENT}" "${NEXT_PAIR}" 1>&2; fi; fi; done; flock -u ${WAL_LOCK_FD}; exec {WAL_LOCK_FD}<&-; rm "${WAL_SEGMENT}.ac_lock"; if [ ${TRANSFER_ERRORS} -eq 0 ]; then exit 0; else exit 4;