Permalink
Browse files

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.
  • Loading branch information...
1 parent 417a3a3 commit 018bd41edf9b5755099f996b3f8ddc43fde133c0 @stephane committed Jan 13, 2011
Showing with 3 additions and 2 deletions.
  1. +3 −2 src/modbus-tcp.c
View
@@ -20,6 +20,7 @@
#include <string.h>
#include <errno.h>
#include <unistd.h>
+#include <signal.h>
#include <sys/types.h>
#if defined(_WIN32)
@@ -32,7 +33,7 @@
# include <sys/socket.h>
# include <sys/ioctl.h>
-#if defined(OpenBSD) || (defined(__FreeBSD__) && __FreeBSD__ < 5)
+#if defined(__OpenBSD__) || (defined(__FreeBSD__) && __FreeBSD__ < 5)
# define OS_BSD
# include <netinet/in_systm.h>
#endif
@@ -434,7 +435,7 @@ modbus_t* modbus_new_tcp(const char *ip, int port)
if (sigaction(SIGPIPE, &sa, NULL) < 0) {
/* The debug flag can't be set here... */
fprintf(stderr, "Coud not install SIGPIPE handler.\n");
- return -1;
+ return NULL;
}
#endif

0 comments on commit 018bd41

Please sign in to comment.