[prev in list] [next in list] [prev in thread] [next in thread] 

List:       rxtx
Subject:    Re: [Rxtx] breaking the deadlock
From:       Gregg Wonderly <gergg () cox ! net>
Date:       2013-01-16 15:41:31
Message-ID: 50F6CA2B.9000906 () cox ! net
[Download RAW message or body]

Every modern day OS which runs Java closes every open file when a process exits 
for any reason.  The OS manages the lifecycle of every part of a running process 
so that there is no chance that the OS data structures are corrupted.

There are however 2 things to know.

1. Some serial port applications written before native file locking was 
available on some OSes, or which are ignoring that locking mechanism, may use an 
external "locking" mechanism, such as the existence of a "lock file" to signify 
usage of a "device".  The "modem" devices (serial ports) in UNIX Oses, have 
historically done this, and because of that, external applications using serial 
ports have lumped in this style of locking.  It is a problem.  Practically, any 
"serial port" library, should always try to "remove" the lock file when it is 
found to exist, and just open it and go.  If the serial stream becomes 
corrupted, the user of the application can look for multiple processes using the 
same serial port.

2. If you enable hardware flow control on a serial port, and you have written 
data to a serial port, which hasn't been sent yet, because the serial cable is 
not wired correctly, or has been removed and caused HW flow control to not 
indicate DSR or CTS or CD as needed, then a "close" may hang, forever, because 
the data is not being sent until the device indicates it is ready to receive 
that data.  Processes which won't exist and can't be killed forcibly indicate 
this type of issue has occurred.

Both of these things are unfortunate attributes of the world of serial ports. 
It's stuff you need to know, and your application needs to be able to deal with 
these issues existing and notifying the user in an appropriate way.

Gregg Wonderly

On 1/16/2013 6:05 AM, Dr. Douglas Lyon wrote:
> Hi All,
> I think that a program running in a JVM can open a serial port
> and then die, leaving the serial port open (perhaps by use of a force
> quit).
>
> When that happens, the serial port remains open and needs to be closed.
>
> Is there anyway to force the serial port to close when it was left
> in a bad state by a prior program?
>
> Thanks!
>   - Doug
> _______________________________________________
> Rxtx mailing list
> Rxtx@qbang.org
> http://mailman.qbang.org/mailman/listinfo/rxtx
>

_______________________________________________
Rxtx mailing list
Rxtx@qbang.org
http://mailman.qbang.org/mailman/listinfo/rxtx
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic