Subject: Re: buffered shell subprocess (Sybase isql)

From: Andrew Innes <[email-masked]>
Date: Tue, 19 Nov 1996 18:44:35 GMT

On Tue, 19 Nov 1996 11:31:45 +0500, "Joseph P. Cernada" <[email-masked]> said:
>
>I'm using the sql-mode (with Sybase isql) on NT Emacs 19.34 and my
>shell subprocess seems to buffer its output.  If I do short database
>selects the data doesn't show up in the buffer, but when I do longer
>selects the data comes back (including the data from the previous
>short select).
>
>Does the subprocess output (to my shell window) get buffered in some
>way?  Is there some way to flush the output so I can see it right
>away?

Most console applications will buffer stdout automatically if it is not
a "tty" (that is, if stdout is not a handle for the console window).
When running in an Emacs shell buffer, stdout is a pipe handle, so it
will be buffered by default.

Note that it is the C stdio runtime that calls isatty() to decide
whether to buffer or not.  The program can call setbuf/setvbuf to change
this.

It is necessary for the program to explicitly disable buffering in order
to work interactively in a shell buffer.  Shell programs themselves do
this, or have an option like -i to force it.  Many other programs are
non-interactive in any case, so their output will be flushed when they
exit.

>Is this something peculiar to the Sybase isql program?  If I try to
>run it in a shell window (not through the sql-mode) it also exhibits
>the same behaviour (buffering of output).

If buffering happens even when run straight from a normal DOS prompt,
then it sounds like the isql program deliberately or accidentally leaves
buffering turned on for stdout.  (The C libraries for most Unix
compilers do this, for example.)

AndrewI