function [str,cleanup]=pipein(cmd,q)
	if nargin<2, q=false; end
	if ~q, fprintf('Starting sub-process: %s\n',cmd); end
	process=java.lang.Runtime.getRuntime().exec({'bash','-c',cmd});
	str=process.getInputStream();
	cleanup=@dispose;

	function dispose
		if ~q, fprintf('Killing subprocess...\n'); end
		process.destroy();
	end
end
