Date: Fri, 6 Feb 1998 00:13:32 +0000 (GMT) From: Terry Lambert <tlambert@primenet.com> To: mike@smith.net.au (Mike Smith) Cc: gram@cdsec.com, freebsd-hackers@FreeBSD.ORG Subject: Re: Shared memory and signals Message-ID: <199802060013.RAA28310@usr09.primenet.com> In-Reply-To: <199802051118.VAA00292@word.smith.net.au> from "Mike Smith" at Feb 5, 98 09:48:42 pm
next in thread | previous in thread | raw e-mail | index | archive | help
> > I was wondering whether it is safe to call shmdt and shmctl from within > > a signal handler. I have a program which forks off child processes which > > communicate their results back using a shared memory segment. I would like > > the parent to detach and release the shared memory from within the SIGCHLD > > signal handler, but I'm not sure whether this is safe. > > Can you do this more cleanly by calling wait4? Unless you are sleeping > on something inside the segment, I can't *think* of any reentrancy/ > locking issues, but I would be worried about the locking you'd have to > apply around the other datastructures that your handler might be accessing. If you use an mmap'ed file instead of a SysV SHM segment, then you will get resource-tracking cleanup after the last close, like you wanted. The file will stick around, but you can unlink it and use UNIX domain sockets to pass the descriptor between processes, if this is a problem. Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199802060013.RAA28310>