fix(PICAN): align socket handling with PIEthernet patterns

- Sentinel: sock = 0 → sock = -1 (0 is stdin, valid fd)
- openDevice(): close socket on ioctl/bind failure (resource leak)
- openDevice(): set O_NONBLOCK via fcntl after socket()
- openDevice(): check setsockopt() return value
- closeDevice(): call shutdown() before close(), reset sock to -1
- readDevice() / writeDevice(): guard against sock == -1
- Add missing #include <fcntl.h>
This commit is contained in:
2026-08-05 17:39:35 +03:00
parent 216109b8ed
commit e89ae88f3a
2 changed files with 19 additions and 4 deletions
+1 -1
View File
@@ -73,7 +73,7 @@ protected:
private:
PRIVATE_DECLARATION(PIP_EXPORT)
int sock;
int sock = -1;
int can_id, readed_id;
};