Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

programming question



I think you misunderstand how fork/exec work in Unix. The Setvbuf(3) 
library function is a stdio function that works on stdio streams. The 
property of stdio streams is not preserved accross the exec because it is a 
property of a stream pointer. Open files are preserved (eg. file descriptors 
0, 1, 2, ...). The stream structure (eg FILE *) is a structure created in your 
program's heap by the fopen(3) function. The C language initialization 
creates the structures for file descriptors 0, 1, and 2. Some of the stdio 
functions used to be inplemented as macros, eg. 
putchar(c) - add 1 character to the buffer. if buffer full or char == '\n' flush it. 
However, you might look at using ioctl(look at the stty command) of fcntl, 
or termio, which work on file descriptors. These can affect the Unix internal 
buffering of a stream.  

On 1 May 99, at 19:31, Jerry A Clabaugh <JerryC at world.std.com> wrote:

> I'm trying to cause an executable to change it's default buffering scheme
> from outside the program. I need this for an IPC application.
> 
> What I thought _should_ work was
> 
> setvbuf stdout to the new buffering scheme
> execl the target program
> 
> Supposedly an exec should cause all open file attributes to be the same in
> the target program, but when the target starts up, it always changes to
> the default buffering scheme (line buffer for term output, full buffer for
> file output). This happens on HP-UX and Linux and SunOS.
> 
> For some targets, I don't have the source, so I can't insert fflushes and
> setvbufs.
> 
> Anyone know anyway around this?
> 
> 
> Thanks
> 
> -
> Subcription/unsubscription/info requests: send e-mail with
> "subscribe", "unsubscribe", or "info" on the first line of the
> message body to discuss-request at blu.org (Subject line is ignored).


+------------------------------------------------------+
|  Gerald Feldman	<gaf at blu.org>                  |
|  Boston Computer Solutions and Consulting            |
|  ICQ#156300                                          |           |
+------------------------------------------------------+
-
Subcription/unsubscription/info requests: send e-mail with
"subscribe", "unsubscribe", or "info" on the first line of the
message body to discuss-request at blu.org (Subject line is ignored).




BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org