Inter-process communication - Mailing list pgsql-interfaces

From Steven Bradley
Subject Inter-process communication
Date
Msg-id 3.0.5.32.19990625172735.009266d0@poptop.llnl.gov
Whole thread Raw
Responses Re: [INTERFACES] Inter-process communication  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-interfaces
I would like to use the LISTEN and NOTIFY features of Postgres to implement
communication between to proceses connected to Postgres, but I don't want
to "listening" process to use polling to detect notifications.  The
following polling example is given in the Postgres documentation:

  while (1)   {       /*        * wait a little bit between checks; waiting with select()        * would be more
efficient.       */       sleep(1);       /* collect any asynchronous backend messages */       PQconsumeInput(conn);
   /* check for asynchronous notify messages */       while ((notify = PQnotifies(conn)) != NULL)       {
fprintf(stderr,               "ASYNC NOTIFY of '%s' from backend pid '%d' received\n",
notify->relname,notify->be_pid);           free(notify);       }   }
 


Instead, I would rather use the "more efficient select(2)" method alluded
to in the Postgres documentation (and code above).  Does anyone have
sample code that uses this method to wait for a backend notification to
arrive?


Thanks in advance...

Steven Bradley
Lawrence Livermore National Laboratory
sbradley@llnl.gov




pgsql-interfaces by date:

Previous
From: "Chay Wesley"
Date:
Subject: Re: [INTERFACES] ODBC 6.4 + PostgreSQL 6.5 = Can't browse tables
Next
From: Peter T Mount
Date:
Subject: Re: [INTERFACES] Problems using, IE5 MS-VM and JDBC driver