I’m having trouble getting pulse notification using mq_notify to work with
Photon app under QNX 6.2.1B. I’ve appended a very simple receiver and
sender below. The sender seems to work (I can see the message count
incrementing on the file), but the receiver never notices the new messages.
This taken almost exactly from the example in the “Interprocess
Communication” chapter of the Photon guide. Any help will be appreciated.
-msgrecv.c------------------------------------------------------------------
/* AppBuilder Photon Code Lib /
/ Version 2.01 */
/* Standard headers */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <mqueue.h>
#include <fcntl.h>
/* Local headers */
#include “ablibs.h”
#include “abimport.h”
#include “proto.h”
/* Application Options string /
const char ApOptions[] =
AB_OPTIONS “”; / Add your options in the “” */
mqd_t Queue = -1;
struct sigevent Signal;
static int MessageHandler( void *data, int rcvid,
void *message, size_t mbsize )
{
ssize_t sz;
unsigned prio;
char buf[ 10 ];
while( (sz = mq_receive( Queue, buf, sizeof( buf ), &prio )) >= 0 )
{
printf( “recvd: %s\n”, buf );
}
mq_notify( Queue, &Signal );
return( Pt_CONTINUE );
}
int
Init( int argc, char *argv[] )
{
int pulse;
/* eliminate ‘unreferenced’ warnings */
argc = argc, argv = argv;
pulse = PtAppCreatePulse( NULL, -1 );
PtAppAddInput( NULL, pulse, MessageHandler, NULL );
PtPulseArm( NULL, pulse, &Signal );
Queue = mq_open( “my_queue”, O_RDONLY | O_CREAT | O_NONBLOCK,
S_IRUSR | S_IWUSR, NULL );
mq_notify( Queue, &Signal );
return( Pt_CONTINUE );
}
-msgsend.c-----------------------------------------------
#include <unistd.h>
#include <fcntl.h>
int main( void )
{
int fd;
char buf[ 10 ] = “Print Me”;
fd = open( “my_queue”, O_WRONLY );
if ( fd != -1 )
write( fd, buf, sizeof( buf ) );
return 0;
}