Skip to content

Commit 4620c35

Browse files
bosilcaabouteiller
authored andcommitted
Prevent EPIPE on OSX.
Signed-off-by: George Bosilca <[email protected]>
1 parent f1ae036 commit 4620c35

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

opal/mca/btl/tcp/btl_tcp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ struct mca_btl_tcp_module_t {
184184
typedef struct mca_btl_tcp_module_t mca_btl_tcp_module_t;
185185
extern mca_btl_tcp_module_t mca_btl_tcp_module;
186186

187-
#define CLOSE_THE_SOCKET(socket) {(void)shutdown(socket, SHUT_RDWR); (void)close(socket);}
187+
#define CLOSE_THE_SOCKET(socket) {OPAL_OUTPUT_VERBOSE((20, opal_btl_base_framework.framework_output, "CLOSE FD %d at %s:%d", socket, __FILE__, __LINE__)); (void)shutdown(socket, SHUT_RDWR); (void)close(socket);}
188188

189189
/**
190190
* TCP component initialization.

opal/mca/btl/tcp/btl_tcp_endpoint.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,17 @@ void mca_btl_tcp_set_socket_options(int sd)
660660
strerror(opal_socket_errno), opal_socket_errno));
661661
}
662662
#endif
663+
#if defined(SO_NOSIGPIPE)
664+
/* Some BSD flavors generate EPIPE when we write to a disconnected peer. We need
665+
* the prevent this signal to be able to trap socket shutdown and cleanly release
666+
* the endpoint.
667+
*/
668+
int optval2 = 1;
669+
if(setsockopt(sd, SOL_SOCKET, SO_NOSIGPIPE, (char *)&optval2, sizeof(optval2)) < 0) {
670+
BTL_ERROR(("setsockopt(SO_NOSIGPIPE) failed: %s (%d)",
671+
strerror(opal_socket_errno), opal_socket_errno));
672+
}
673+
#endif
663674
}
664675

665676

orte/mca/odls/base/odls_base_default_fns.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,9 +1729,10 @@ void orte_odls_base_default_wait_local_proc(int fd, short sd, void *cbdata)
17291729
proc->exit_code = WTERMSIG(proc->exit_code) + 128;
17301730

17311731
OPAL_OUTPUT_VERBOSE((5, orte_odls_base_framework.framework_output,
1732-
"%s odls:waitpid_fired child process %s terminated with signal",
1732+
"%s odls:waitpid_fired child process %s terminated with signal (%d)",
17331733
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
1734-
ORTE_NAME_PRINT(&proc->name) ));
1734+
ORTE_NAME_PRINT(&proc->name),
1735+
proc->exit_code ));
17351736
/* Do not decrement the number of local procs here. That is handled in the errmgr */
17361737
}
17371738

0 commit comments

Comments
 (0)