Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!uunet!nuchat!sugar!peter
From: peter@sugar.UUCP (Peter da Silva)
Newsgroups: comp.sys.amiga
Subject: Re: How to cd, and disk drive trouble
Message-ID: <1237@sugar.UUCP>
Date: Mon, 7-Dec-87 06:29:47 EST
Article-I.D.: sugar.1237
Posted: Mon Dec  7 06:29:47 1987
Date-Received: Sun, 13-Dec-87 01:41:51 EST
References: <796@rocky.STANFORD.EDU>
Organization: Sugar Land UNIX - Houston, TX
Lines: 25
Summary: DeadLock

In article <796@rocky.STANFORD.EDU>, ali@rocky.STANFORD.EDU (Ali Ozer) writes:
> What's the correct way to change directories in a program without going
> back to the original directory at the end? You first obtain a lock, with
> ACCESS_READ, then you examine it to make sure it is a directory, then you
> do a CurrentDir(). That's where the program ends. Now, do you need an
> UnLock() on the original lock you obtained? Without the UnLock(), everything
> seems to work fine, even after the program is done. With an UnLock(), 
> the program exists fine, except the first dos operation you do ("dir," for
> instance), the machine hangs. Everything I read says to do an UnLock()
> on every lock obtained, though, so what's wrong? This is with Manx 3.40a.

You UnLock() any lock *you* obtain (==Lock()). Your original directory wasn't
Lock()ed by you, so you better not UnLock it. Otherwise either CLI will be
trying to work without a valid lock (accessed next time you do a dir), or
Workbench will be UnLocking an UnLocked lock, or maybe even using it!

I am not sure if you're doing this or not. Let's parse that message again.

When you do a CurrentDir(), you also need to keep that lock around as long
as you're in that directory. When you finish, CurrentDir() back to your
original directory's lock (returned from CurrentDir()). THEN you can trash
the new lock. You doing that?
-- 
-- Peter da Silva  `-_-'  ...!hoptoad!academ!uhnix1!sugar!peter
-- Disclaimer: These U aren't mere opinions... these are *values*.