Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 Jan 2001 16:31:26 +0100 (CET)
From:      Michal Zapasnik <bigstar@astercity.net>
To:        freebsd-questions@freebsd.org
Subject:   System functions in BSD and others *nix systems.
Message-ID:  <Pine.BSF.4.21.0101181618110.570-100000@BS.home.astercity.net>

next in thread | raw e-mail | index | archive | help
Hi all

I was writeing simple program for school using system funcions
msgget, msgsnd and msgrcv. This program run fine on other OS
i tested it on debian,RedHat and SunOS on my FreeBSD box
the resaults are bad. Are the system funcion different in FBSD?
This is my simple program

--- queue.h ---
#define ONE ftok("/home/bigstar/one.c" , '0')
struct data {
  int mtype;
  int mtext;
};

--- one.c ---
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#include <stdio.h>
#include <unistd.h>
#include "queue.h"
int main()
{
  int q, i;
  struct data msg;
  q=msgget(ONE,IPC_CREAT|0660);
  msg.mtype = 1;
  msg.mtext = 5;
  for (i=0; i<10; i++)
  {
    msgsnd(q, &msg, sizeof(msg), 0);
    sleep(1);
  }
}

--- two.c --- 
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#include <stdio.h>
#include <unistd.h>
#include "queue.h"

int main()
{
  int q, i;
  struct data msg;
  q=msgget(ONE,IPC_CREAT|0666);
  for (i=0; i<10; i++)
  {
    msgrcv(q, &msg, sizeof(msg), 0, 0);
    printf("I recive: %d \n", msg.mtext);
   }
}
 

When i run ./one | ./two on FreeBSD i get 
 I recive: 671473920
and sa on as i wrote on other tested OS it works fine.

Anyone know where the problem is?

BS.


 




To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0101181618110.570-100000>