Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 14 Aug 1999 18:11:09 -0700 (PDT)
From:      Matthew Dillon <dillon@apollo.backplane.com>
To:        Marc Tardif <intmktg@CAM.ORG>
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: shared memory crash
Message-ID:  <199908150111.SAA98382@apollo.backplane.com>
References:   <Pine.SOL.4.10.9908141533380.25252-100000@Ocean.CAM.ORG>

next in thread | previous in thread | raw e-mail | index | archive | help
: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 
					<dillon@backplane.com>



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




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