Hi

A general question first: is there a way to pass a function pointer between two user
space applications in Linux, using a message queue (msgsnd, msgget pair)?

Assuming that this can be done, here is what I'm trying to do:
================================
In a header file I've defined:
================================
Code:
typedef struct msgbuf{
   int mtype;
   int (*ptr)();
   } message_buf;

int myfunc(int);
================================
In the sending application:
=================================
Code:
int myfunc(int mdata){
   /*Do something */
   return 0;   
};
.
.
.
   struct msgbuf* m_msg; /* Structure used for received messages. */
   int queue_id;         /* ID of the created queue. */
   int i;

   /* Access the public message queue. */
   queue_id = msgget(QUEUE_ID, 0);
   if (queue_id == -1) {
      perror("msgget");
      exit(1);
   }

   /* Allocate space for message */
   m_msg = (struct msgbuf*)malloc(sizeof(struct msgbuf)+MAX_MSG_SIZE);

   /* Set valid message type. */
   m_msg->mtype = VALID_TYPE;

   /* Set function. *** HOPING THIS IS RIGHT ***/
   m_msg->ptr = myfunc;

   /* Send message */
   i = msgsnd(queue_id, m_msg, sizeof(struct msgbuf)+1, 0);
   if (rc == -1) {
      perror("msgsnd");
      exit(1);
   } 

   /* Free allocated memory. */
   free(m_msg);
.
.
.
================================
In the receiving application:
=================================
Code:
  struct msgbuf * m_msg; /* Structure used for messages. */
  int i;
  int (*func)(int);
.
.

   while (1) {
      i = msgrcv(m_qid, m_msg, MAX_MSG_SIZE+1, VALID_TYPE, 0);
      if (rc == -1) {
         perror("msgrcv");
         exit(1);
      }
      func = m_msg->cb_ptr;
      /*** HERE IS THE PROBLEM. SEGMENTATION FAULT WHEN REACHED ***/
      i = func(100);
   }
.
.
Any help, even more a sample code or link, is more than welcome.

LxRz