From mboxrd@z Thu Jan 1 00:00:00 1970 From: erik quanstrom Date: Wed, 30 Sep 2009 09:25:35 -0400 To: 9fans@9fans.net Message-ID: <8c0180e1040b5ab14761083fdd1b9600@brasstown.quanstro.net> In-Reply-To: <<9d12d327612343c13bd110253c2632c6@9grid.es>> References: <<9d12d327612343c13bd110253c2632c6@9grid.es>> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: Re: [9fans] exiting nicely Topicbox-Message-UUID: 79b4f012-ead5-11e9-9d60-3106f5b1d025 > I have a couple of processes working together sharing memory and using locks, and when the program finish the job and exits, the proceses in Rendez state does not exit, and i need to slay them. > > I'm using postnote(PNGROUP,...) call, should i write a postctl to slay the waiting proceses or is there a better way to accomplish this? (may be using canlock and wait for it with a loop and sleep instead of a qlock?) looping on canq?lock is not a good idea. i think what you want is to ensure that no proc is doing anything that shouldn't be interrupted when it is killed or quits. for many programs, interrupting writes is a bad idea. one would want a half-written upas index file, for instance. rc checks a global sentinal at a few strategic points (where it can clean up easily) when it receives a signal. perhaps you could borrow this technique, as in /* * exit the building single file */ void chkexit(QLock *q) { if(!exiting) return; qunlock(q) cleanexit(); } ... qlock(&resourcelk); chkexit(&resourcelk); ... qunlock(&resourcelk); this might not be appropriate. the bad things that might happen if your interrupted in the middle of something might not be bad enough to worry about or this might be difficult to implement with your program. - erik