Skip site navigation (1) Skip section navigation (2)

Re: Function written in C, hangs on one machine and not another...

From: CG <cgg007(at)yahoo(dot)com>
To: Douglas McNaught <doug(at)mcnaught(dot)org>,Dennis Jenkins <dennis(dot)jenkins(at)sbcglobal(dot)net>
Cc: postgresql listserv <pgsql-general(at)postgresql(dot)org>
Subject: Re: Function written in C, hangs on one machine and not another...
Date: 2005-10-28 20:17:01
Message-ID: 20051028201701.27586.qmail@web32505.mail.mud.yahoo.com (view raw or flat)
Thread:
Lists: pgsql-general
Thanks to the great suggestions I've at least gotten it to not hang... 

Martijn's hint about blocking led me to open up those filehandles in a
non-blocking mode. It appears that write() will write, at a maximum, only 4096
bytes when it is called from within PostgreSQL. I've tried to push data into it
in <=4096-byte slugs, but after 4096 bytes it just won't take anymore. Since (I
think) using a non-blocking mode could cause problems with thread safety, it's
probably a lost cause.

I'm new to C, so this may seem extremely naive: I'm not sure how to use exec()
to solve this problem. Could you give me a few pointers to get me started?



--- Douglas McNaught <doug(at)mcnaught(dot)org> wrote:

> Martijn van Oosterhout <kleptog(at)svana(dot)org> writes:
> 
> > The things that have screwed me up in the past with pulling tricks like
> > this are:
> >
> > 1. Program has registered atexit() handlers. _exit() avoids this.
> > 2. Pending stdio output that gets flushed. The backend doesn't use
> > stdio much so you might be fine here.
> > 3. Signals. Make sure you don't get sent signals that screw state.
> > Might be wise to block them all, or reset them all to default.
> >
> > Truly, exec() is the cleanest way to solve all this, it simply replaces
> > the current process, lock, stock and barrel.
> 
> Definitely.  It would probably also be good to close all file
> descriptors (except for stdin/etdout/stderr) before exec(), just in
> case the other binary does something screwy with random file
> descriptors (which it obviously shouldn't).
> 
> -Doug
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
> 





		
__________________________________ 
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com

In response to

Responses

pgsql-general by date

Next:From: Benjamin SmithDate: 2005-10-28 20:47:49
Subject: Frequency of Analyze?
Previous:From: William YuDate: 2005-10-28 18:46:01
Subject: Re: FoxPro in WINE to Postgresql on LINUX?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group