From owner-ntemacs-users@june  Tue Nov 19 11:35:30 1996
X-VM-v5-Data: ([nil nil nil nil nil nil nil nil nil]
	[nil "Tue" "19" "November" "1996" "18:44:35" "GMT" "Andrew Innes" "andrewi@harlequin.co.uk" nil "37" "Re: buffered shell subprocess (Sybase isql)" "^From:" nil nil "11" nil nil nil nil]
	nil)
Received: from joker.cs.washington.edu (joker.cs.washington.edu [128.95.1.42]) by june.cs.washington.edu (8.8.3/7.2ju) with SMTP id LAA29954 for <voelker@june.cs.washington.edu>; Tue, 19 Nov 1996 11:35:30 -0800
Received: from june.cs.washington.edu (june.cs.washington.edu [128.95.1.4]) by joker.cs.washington.edu (8.6.12/7.2ws+) with ESMTP id LAA28559 for <voelker@joker.cs.washington.edu>; Tue, 19 Nov 1996 11:35:24 -0800
Received: from holly.cam.harlequin.co.uk (holly.cam.harlequin.co.uk [193.128.4.58]) by june.cs.washington.edu (8.8.3/7.2ju) with SMTP id KAA26170 for <ntemacs-users@cs.washington.edu>; Tue, 19 Nov 1996 10:44:49 -0800
Received: from propos.long.harlequin.co.uk by holly.cam.harlequin.co.uk; Tue, 19 Nov 1996 18:44:39 GMT
Received: from elan.long.harlequin.co.uk (elan [193.128.93.78]) by propos.long.harlequin.co.uk (8.6.12/8.6.12) with SMTP id SAA08643; Tue, 19 Nov 1996 18:44:35 GMT
Message-Id: <199611191844.SAA08643@propos.long.harlequin.co.uk>
In-Reply-To: <9611191631.AA15870@tolani.tpg.com> (joec@tpg.com)
From: Andrew Innes <andrewi@harlequin.co.uk>
To: joec@tpg.com
Cc: ntemacs-users@cs.washington.edu
Subject: Re: buffered shell subprocess (Sybase isql)
Date: Tue, 19 Nov 1996 18:44:35 GMT

On Tue, 19 Nov 1996 11:31:45 +0500, "Joseph P. Cernada" <joec@tpg.com> 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

