Commit 018bd41edf9b5755099f996b3f8ddc43fde133c0

Authored by Stéphane Raimbault
1 parent 417a3a38

Fix compilation on OpenBSD

In modbus-tcp.c:
- Needed to include <signal.h>
- Added Jay's fix for __OpenBSD__
- SIGPIPE ignore handler needs to return a pointer instead of an integer.

Patch provided bu Barry Grumbine and Jason Oster.
Showing 1 changed file with 3 additions and 2 deletions
src/modbus-tcp.c
... ... @@ -20,6 +20,7 @@
20 20 #include <string.h>
21 21 #include <errno.h>
22 22 #include <unistd.h>
  23 +#include <signal.h>
23 24 #include <sys/types.h>
24 25  
25 26 #if defined(_WIN32)
... ... @@ -32,7 +33,7 @@
32 33 # include <sys/socket.h>
33 34 # include <sys/ioctl.h>
34 35  
35   -#if defined(OpenBSD) || (defined(__FreeBSD__) && __FreeBSD__ < 5)
  36 +#if defined(__OpenBSD__) || (defined(__FreeBSD__) && __FreeBSD__ < 5)
36 37 # define OS_BSD
37 38 # include <netinet/in_systm.h>
38 39 #endif
... ... @@ -434,7 +435,7 @@ modbus_t* modbus_new_tcp(const char *ip, int port)
434 435 if (sigaction(SIGPIPE, &sa, NULL) < 0) {
435 436 /* The debug flag can't be set here... */
436 437 fprintf(stderr, "Coud not install SIGPIPE handler.\n");
437   - return -1;
  438 + return NULL;
438 439 }
439 440 #endif
440 441  
... ...