From owner-freebsd-hackers Tue Feb 3 23:52:49 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id XAA07985 for hackers-outgoing; Tue, 3 Feb 1998 23:52:49 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from safeconcept.utimaco.co.at (mail-gw.utimaco.co.at [195.96.28.162]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id XAA07980 for ; Tue, 3 Feb 1998 23:52:43 -0800 (PST) (envelope-from Michael.Schuster@utimaco.co.at) Received: (from uucp@localhost) by safeconcept.utimaco.co.at (8.8.5/8.8.5) id IAA04289 for ; Wed, 4 Feb 1998 08:32:48 +0100 (CET) Received: from ultra1.utimaco.co.at(10.0.0.32) by safeconcept via smap (V2.0) id xma004287; Wed, 4 Feb 98 08:32:26 +0100 Message-ID: <34D81DAD.F3B30021@utimaco.co.at> Date: Wed, 04 Feb 1998 08:50:05 +0100 From: Michael Schuster Organization: Utimaco Safe Concept GmbH. Linz Austria X-Mailer: Mozilla 4.04 [en] (X11; I; SunOS 5.5.1 sun4u) MIME-Version: 1.0 To: "hackers@FreeBSD.ORG" Subject: Re: Shared memory and signals References: <199802040717.RAA07706@cain.gsoft.com.au> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG X-To-Unsubscribe: mail to majordomo@FreeBSD.org "unsubscribe hackers" Daniel O'Connor wrote: > Hmm, yes but I know of at least one program (paradise netrek :) which uses the > fact that the shared mem segment is persistent... Shared memory is persistent in the sense that you can do something like typedef struct { int magic; .... } my_struct; void *mem; int size = sizeof (my_struct); key_t key = MY_KEY; /* some constant key */ fd = shmget (key, size, ...); mem = shmat (fd, ...); if (((my_struct *) mem)->magic == MY_MAGIC) { /* re-attached */ /* re-use memory .... */ } else { /* do what you have to do with newly attached mem */ ((my_struct *) mem)->magic = MY_MAGIC; } /* ..... */ shmdt (mem); as often as you like, and you (and any other process) will always get the same memory segment (although the pointers may not be the same - they're virual addresses, of course) with the contents you left in there the last time you used it (provided noone has changed it, of course). Once you IPC_RM it even once though, it's gone (in fact you can only IPC_RM it once; subsequent IPC_RMs will give you an invalid argument error) and lost immediately for all and any process. -- Michael Schuster