From: Leslie P. P. <sk...@vi...> - 2010-04-28 16:36:29
|
On Wed, Apr 28, 2010 at 07:28:24PM +0300, Teemu Likonen wrote: > * 2010-04-26 09:11 (+0200), Leslie P. Polzer wrote: > > > Here's a quick working sketch: > > > (without-package-locks > > (defun sb-impl::flush-standard-output-streams () > > (ignore-errors > > (dolist (name '(*debug-io* > > *error-output* > > *query-io* > > *standard-output* > > *trace-output* > > *terminal-io*)) > > ;; FINISH-OUTPUT may block more easily than FORCE-OUTPUT > > (force-output (symbol-value name))) > > (values)))) > > > > > > (format t "one~%two~%three~%") > > Redefining an internal function seems ugly. I do appreciate your help > and efforts, though. So really, thank you. It's just a kludge to fix this until we have a sane solution in upstream. I happen to need this functionality too for one of my projects so I might write a proper patch soon. Of course this will take some time, and more still until the patch is committed. > Unfortunately I don't understand the problem fully myself and most > likely that's the reason I couldn't get your "quick working sketch" > working. With the above code (at script's top level) and my original > test script I still get the same "broken pipe" error when the output is > piped to "head -n1". There's a bunch of output preceding the actual program's output, like the version/license banner. When the pipe breaks before we have a chance to redefine sb-impl::flush-standard-output-streams then our code won't change anything. Try the --script switch (cuts down banner size to one line) and -n2 with head. Furthermore add another IGNORE-ERRORS around the FORMAT form since the output might go straight to stdout instead of being buffered. I can post a full transcript next time if you can't get the same results. Leslie |