Skip to content

Commit

Permalink
modbus-rtu: don't use O_EXCL when opening the device
Browse files Browse the repository at this point in the history
Quote from 'man 2 open':
-snip-
...
In general, the behavior of O_EXCL is undefined if it is used without O_CREAT.
...
-snap-

Since we don't create the device file here - we just want to open
(hopefully) existing ones - let's simply drop this flag to be on
the safe side.

Signed-off-by: Michael Heimpold <mhei@heimpold.de>
  • Loading branch information
mhei committed Jul 27, 2024
1 parent dde16d5 commit de462c7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/modbus-rtu.c
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ static int _modbus_rtu_connect(modbus_t *ctx)
Timeouts are ignored in canonical input mode or when the
NDELAY option is set on the file via open or fcntl */
flags = O_RDWR | O_NOCTTY | O_NDELAY | O_EXCL;
flags = O_RDWR | O_NOCTTY | O_NDELAY;
#ifdef O_CLOEXEC
flags |= O_CLOEXEC;
#endif
Expand Down

0 comments on commit de462c7

Please sign in to comment.