Locking issue with serial port
Hi,
In my application,I need to monitor the devices connected through serial port in solaris sparc 9 OS.I used c and java code for it and I am able to do the same but the problem comes when I restart the system and the open my application and try to monitor it.but I m unable to monitor the devices and getting the message -- Quote:
So plz let me know why it is happening and how to solve it. Thanks in advance.. |
It sounds like you simply need to perform a graceful shutdown of the system, in order for the lockfile(s) to be removed.
--- rod. |
Quote:
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:
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: Code:
man lsof Hope this helps. |
Hi,
I checked the code and i found out that when i restart the system,locked file is present in /var/lock dir but my application is unable to communicate it and throws the exception- Quote:
Please provide ur valuable ideas.. thanks in advance.... |
Quote:
1. Change your code to be more bulletroof about how it shuts itself down. 2. Test your changes by running the application and then forcing an abnormal exit: Code:
# kill -9 (your process ID) |
All times are GMT -5. The time now is 02:56 AM. |