Quote:
Originally Posted by theNbomr
It sounds like you simply need to perform a graceful shutdown of the system, in order for the lockfile(s) to be removed.
|
Lock files, if used properly, shouldn't depend on graceful shutdown. They should be equally usable even with a crash caused, say, by power failure.
A lock file should be used by opening (creating, if necessary) the lock file and locking it. If for some reason the process which locks the file goes away, then the lock is removed from the file and some other process should be able to lock the file. There should never be a reason to actually
remove the file.
But this message:
Quote:
Warning: The serial port "/dev/term/a" cannot be opened for use.
Please verify that it is entered correctly and that it is not already in use.
|
rather implies that the problem is not with the lock file, but with the serial port itself. Is that true? Look at the code which generates this message, and determine whether the message is triggered by:
- a failure opening the serial port itself;
- a determination that the lock file already exists;
- a failure to lock the lock file; or
- something else.
If it's (1), then maybe the code isn't using the lock file properly, and thinks that it's OK to continue, and then fails on opening the serial port.
If it's (2), then the code is not using lock files properly. Don't blow up if the lock file exists; blow up if you can't lock it. That's why it's called a lock file.
If it's (3), then somehow there's a process which already (or still) has the lock file locked. It's quite possible for you to delete a file that has a lock on it (and the lock will still continue to be on this phantom file). But if you delete it, your program can then go in and create a new lock file and lock it, oblivious to the fact that some other process thinks it still has the file locked.
This is the most likely possibility, since deleting the lock file lets your program run. Find out why it still has a lock on it. Which process has that file still open? To do that, when you encounter this difficulty, instead of just deleting the file, use lsof. For more information, enter this at the shell prompt:
This should open your eyes to what else is going on that you might not have considered.
Hope this helps.