Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 18 Sep 1995 14:18:53 -0700 (PDT)
From:      Tim Strayer <strayer@lucky.ca.sandia.gov>
To:        questions@freebsd.org
Subject:   Shared Memory and ftok()
Message-ID:  <9509182118.AA23402@lucky.ca.sandia.gov>

next in thread | raw e-mail | index | archive | help
Hello,

I am trying to use shm and ftok on FreeBSD 2.1.0.

The function call "shmget()", when called, produces

   Bad system call (core dumped)

Does shared memory exist in FreeBSD 2.1? Here's the test program
I used:

#include <stdio.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/errno.h>

main() {
   int shmflg = 0606 | IPC_CREAT | IPC_EXCL;
   int shmid = shmget(15, 200, shmflg);
   if (shmid == -1) {
      perror("shmget");
      exit(1);
   }

   printf("shmid: %d\n", shmid);
}

I compiled it with g++ and no other flags. This works on all of my
other machines.

The function call "ftok()" is supposed to create a toke to use with
the SysV IPC facilities like shared memory. I have tried a simple
program that calls ftok:

#include <stdio.h>
#include <sys/types.h>
#include <sys/ipc.h>

main() {
   key_t my_key;
   my_key = ftok("/etc/passwd", (char)15);
   printf("hello: %d\n", (int)my_key);
}

compiled with g++, gcc, and cc, and including the compatibility library
libcompat.a. The error

   <filename>.o: Undefined symbol `_ftok' referenced from text segment

always occurs. When I pull the "ftok.o" out of /usr/lib/libcompat.a
and include that file on the compile line, the program compiles and
runs just fine. Is there something else I need in order to get the
program to compile with this library?

I've used shared memory and ftok on many architectures, and I know
that each one is somewhat different and requires something special 
to get it to compile and run. If you know of special things I have
to do for FreeBSD, I would appreciate hearing from you.

Thanks for your help,
-Tim.

--------------------------------------------------------------------
W. Timothy Strayer                      Sandia National Laboratories
Distributed Systems Research             P.O. Box 969, Mailstop 9011
(510) 294-3671 (OFFICE)                     Livermore, CA 94551-0969
(510) 294-1225 (FAX)                           strayer@ca.sandia.gov




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?9509182118.AA23402>