From owner-freebsd-hackers Sat Aug 14 18:10:53 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from apollo.backplane.com (apollo.backplane.com [209.157.86.2]) by hub.freebsd.org (Postfix) with ESMTP id 3208C14D9D for ; Sat, 14 Aug 1999 18:10:51 -0700 (PDT) (envelope-from dillon@apollo.backplane.com) Received: (from dillon@localhost) by apollo.backplane.com (8.9.3/8.9.1) id SAA98382; Sat, 14 Aug 1999 18:11:09 -0700 (PDT) (envelope-from dillon) Date: Sat, 14 Aug 1999 18:11:09 -0700 (PDT) From: Matthew Dillon Message-Id: <199908150111.SAA98382@apollo.backplane.com> To: Marc Tardif Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: shared memory crash References: Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG :I've been learning to program using shared memory and messages. As I write :and debug, I often have to crash a running process which stalls. Of :course, there is a problem with my code but that's all part of the :learning process. The actual problem is that, after a few ctrl-c's, there :isn't enough space to allocate the shared memory space required. A :solution suggested in previous discussions in the freebsd mailing list is :to increase the SHMMAX value in the kernel config, but I'd rather find a :way to recuperate the space I've been wasting needlessly on crashed :processes. : :Thanks in advance, :Marc The problem is due to the way SysV shared memory semantics work. Destroying the process does *NOT* delete the shared memory segment. You can use the 'ipcs -a' command to list currently allocated segments, and you can use 'ipcrm' to delete them. The only way to delete a shared memory segment automatically is to have the program delete the segment after creating it, leaving just the mapping. The program can fork() and the shared map will still be shared across forks, but no new program can open access to the shared map when you do this. When the last reference goes away, the system will destroy the map. Alternatively you can use a static identifier to create the segment. Your program can then detect that a segment already exists, delete it, and re-create it. -Matt Matthew Dillon To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message