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

From: CG <cgg007(at)yahoo(dot)com>
To: postgresql listserv <pgsql-general(at)postgresql(dot)org>
Subject: Function written in C, hangs on one machine and not another...
Date: 2005-10-28 13:38:29
Message-ID: 20051028133830.20569.qmail@web32515.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

PostgreSQL 7.4 ...

Essentially, I've written a function in C for use with PostgreSQL. The debugger
shows that the program is hanging on the part of the program that is writing
data into it's own STDIN.

[snip]

// Open up and hijack STDIN
int pipe_pair[2];
int pipe_rv = pipe(pipe_pair);
if (pipe_rv != 0)
// Abort! Abort!
{
close(pipe_pair[1]);
pfree(param_1);
pfree(param_2);
PG_RETURN_NULL();
}

int newfd = dup2(pipe_pair[0],STDIN_FILENO);
if (newfd != 0)
// Abort! Abort!
{
close(pipe_pair[1]);
pfree(param_1);
pfree(param_2);
PG_RETURN_NULL();
}

// Write param_1 to hijacked pipe
write(pipe_pair[1], param_1, param_1_len); // Hangs here...

[/snip]

It works on the machine I use for testing from within PostgreSQL, but it
doesn't work on the machine which is the production server. I'd hate for this
to matter, but I ought to disclose that testing machine is a 1-way AMD Box with
a more recent version of the Linux 2.6 kernel, and a more recent version of
libc. The production machine is a 2-way Dell Xeon processor. Same version of
PostgreSQL, compiled with the same flags (except with debugging symbols for the
testing machine). You'd, or at least I would, think simple code like this would
compile and run on multiple platforms...

I can perform the same STDIN hijacking on both machines in a standalone
program, but it fails under PostgreSQL.

I'm completely stumped, and I need YOUR insight! Thank you!!

CGV


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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message alessandra de gregorio 2005-10-28 13:42:08 serial number in output
Previous Message Kenneth Marshall 2005-10-28 13:31:46 Re: [ANNOUNCE] PostgreSQL 8.1 Beta 4