Revert "Revert "replace deprecated popen2 with subprocess""