Commits

Michał Górny committed dc7905f

Fix looping BashServer when pipes are closed.

Ensure BashServer will exit when stdin is closed (read returns non-zero)
rather than letting it loop and eat CPU.

  • Participants
  • Parent commits 42e7151

Comments (0)

Files changed (1)

gentoopm/bash/bashserver.py

 from gentoopm.exceptions import InvalidBashCodeError
 
 _bash_script = '''
-while true; do
+while
 	(
 		while read -r __GENTOOPM_CMD; do
 			eval ${__GENTOOPM_CMD}
 		done
+		exit 1
 	)
+do
+	:
 done
 '''
 
 		shutil.copyfileobj(envf, f)
 		f.flush()
 
-		self._write('break',
+		self._write('exit 0',
 				'source %s && printf "OK\\0" || printf "FAIL\\0"' % repr(f.name))
 		resp = self._read1()
 		f.close()