diff options
author | Pascal Obry <obry@adacore.com> | 2022-03-24 11:30:05 +0100 |
---|---|---|
committer | Eric Botcazou <ebotcazou@adacore.com> | 2022-03-24 11:31:50 +0100 |
commit | d937c6e44ba64694c0fc88f40f42390149d1d624 (patch) | |
tree | e0b4b52a5a4eb8317858b5b016c5e02b37dfa3cd /gcc | |
parent | 85b4d881327e31ae7d2bd4072dcbe425db30f8fe (diff) | |
download | gcc-d937c6e44ba64694c0fc88f40f42390149d1d624.zip gcc-d937c6e44ba64694c0fc88f40f42390149d1d624.tar.gz gcc-d937c6e44ba64694c0fc88f40f42390149d1d624.tar.bz2 |
Properly reset the port handle when closing
When the serial port is closed, we need to ensure that the port handle is
properly reset for it to be detected as closed.
gcc/ada/
PR ada/104767
* libgnat/g-sercom__mingw.adb (Close): Reset port handle to -1.
* libgnat/g-sercom__linux.adb (Close): Likewise.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/libgnat/g-sercom__linux.adb | 1 | ||||
-rw-r--r-- | gcc/ada/libgnat/g-sercom__mingw.adb | 1 |
2 files changed, 2 insertions, 0 deletions
diff --git a/gcc/ada/libgnat/g-sercom__linux.adb b/gcc/ada/libgnat/g-sercom__linux.adb index a2a64b1..73bbb69 100644 --- a/gcc/ada/libgnat/g-sercom__linux.adb +++ b/gcc/ada/libgnat/g-sercom__linux.adb @@ -382,6 +382,7 @@ package body GNAT.Serial_Communications is begin if Port.H /= -1 then Res := close (int (Port.H)); + Port.H := -1; end if; end Close; diff --git a/gcc/ada/libgnat/g-sercom__mingw.adb b/gcc/ada/libgnat/g-sercom__mingw.adb index aea78ae..d3301bd 100644 --- a/gcc/ada/libgnat/g-sercom__mingw.adb +++ b/gcc/ada/libgnat/g-sercom__mingw.adb @@ -70,6 +70,7 @@ package body GNAT.Serial_Communications is begin if Port.H /= -1 then Success := CloseHandle (HANDLE (Port.H)); + Port.H := -1; if Success = Win32.FALSE then Raise_Error ("error closing the port"); |