Hi all,
I use mbuff module (v0.6.2) to share memory between user and
kernel space.
But after the allocation of mbuff memory, the user process
does a fork(). And when the son dies, I have the message
"closing unknown mbuff c23ed5a0"
But the communication via mbuff works well.
Is it a problem?
Can we use mbuff and fork() in the same user process?
Many thanks.

Clint

PS: code of the user process.

volatile mbf_str_t *buf;

unsigned char   str[512];

void father () {
  while (1) {
    printf("String to write :");
    scanf("%s", str);
    while (buf->sh_flg & SHM_WRITE) {
      printf("WAIT : buffer NOT free!\n");
      sleep(5);
    }
    memcpy((char *)buf->sh_msg, str, strlen(str));
    buf->sh_msg[strlen(str)] = 0;
    buf->sh_flg |= SHM_WRITE;
    if (str[0] == 'q') {
      break;
    }
  }
  mbuff_free(SHM_NAME, (void*)buf);
  return;
}

void son() {
  printf("Start son: buf = 0x%p \n", buf);
  sleep(5);
  printf("End son\n");
  exit(0);
}

int main (int argc,char *argv[]){

  pid_t pid;

  buf = (volatile mbf_str_t *)mbuff_alloc(SHM_NAME, SHM_SIZE);
  if (buf == NULL) {
    printf("mbuff_alloc failed\n");
    exit(2);
  }
  printf("adresse du pointeur : %p\n", buf);

  if ((pid = fork()) < 0) {
    perror("fork");
    exit(1);
  }
  if (pid == 0) {
    son();
  } else {
    printf("pid of son: %d\n", pid);
    father();
  }
  printf("End main\n");
  exit(1);
}

________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com

-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
---
For more information on Real-Time Linux see:
http://www.rtlinux.org/rtlinux/

Reply via email to