Collect with_communicate value in consistent and concise way

Just happened to be reviewing this code to see what it does...

There was a pop for stdin, but very verbose test for with_communicate
Merge pull request #6942 from ajithhub/patch-1

Collect 'with_communicate' value in consistent and concise way