Assuming you're on GNU/Linux:
(setq read-process-output-max
(with-temp-buffer
(insert-file-contents "/proc/sys/fs/pipe-max-size")
(string-to-number (buffer-string))))