Re: A portable code question - Mailing list pgsql-hackers

From Andrew Dunstan
Subject Re: A portable code question
Date
Msg-id 43691.199.90.235.43.1056655123.squirrel@www.dunslane.net
Whole thread Raw
In response to Re: A portable code question  ("Benjamin Minshall" <minshall@intellicon.biz>)
List pgsql-hackers
Or if you want this behaviour all the time, one call of setvbuf(mypipe,(char *)0,_IONBF,0);
should do the trick (much easier than remebering to have to call fflush()
all the time).

If not using streams, and just calling write(), then you probably don't have
to worry.

andrew

BTW, "system('sleep 1');" probably won't compile, and 'system("sleep 1");'
is bad news. Try "man 3 sleep" for more info.

> Assuming you're using file streams to write to the pipe, fflush() will
> do the trick.
>
>> -----Original Message-----
>> From: pgsql-hackers-owner@postgresql.org
>> [mailto:pgsql-hackers-owner@postgresql.org]On Behalf Of
>> nolan@celery.tssi.com
>> Sent: Thursday, June 26, 2003 2:20 PM
>> To: pgsql hackers list
>> Subject: [HACKERS] A portable code question
>>
>>
>> In the little fix I came up with for psql last night, I need to be
>> able to ensure that something sent to a pipe (and then to stdout)
>> completes before issuing the prompt directly to stdout.
>>
>> I did this with: "system ('sleep 1');", but I'm fairly sure that is
>> not portable nor does it ENSURE completion.
>>
>> What's the proper way to do this?  And what's a good book on writing
>> portable code?
>> --
>> Mike Nolan
>>
>> ---------------------------(end of
>> broadcast)--------------------------- TIP 8: explain analyze is your
>> friend
>>
>
>
> ---------------------------(end of
> broadcast)--------------------------- TIP 7: don't forget to increase
> your free space map settings





pgsql-hackers by date:

Previous
From: nolan@celery.tssi.com
Date:
Subject: Re: A portable code question
Next
From: Rod Taylor
Date:
Subject: Re: Two weeks to feature freeze