If I tell pg_basebackup to use a non-existent slot, it immediately reports an error. And then it exits with an error, but only after streaming the entire database contents.
If you are doing this interactively and are on the ball, of course, you can hit ctrl-C when you see the error message.
I don't know if this is exactly a bug, but it seems rather unfortunate.
Should the parent process of pg_basebackup be made to respond to SIGCHLD? Or call waitpid(bgchild, &status, WNOHANG) in some strategic loop?
$ /usr/local/pgsql9_6/bin/pg_basebackup -D data_replica -P --slot foobar -Xs
pg_basebackup: could not send replication command "START_REPLICATION": ERROR: replication slot "foobar" does not exist
22384213/22384213 kB (100%), 1/1 tablespace
pg_basebackup: child process exited with error 1
pg_basebackup: removing data directory "data_replica"
Cheers,
Jeff