Skip to content

Commit 9f4365f

Browse files
authored
Merge pull request #6783 from abouteiller/export/macos-epipe
Prevent EPIPE on OSX.
2 parents 3c0fa53 + 4620c35 commit 9f4365f

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
@@ -190,7 +190,7 @@ struct mca_btl_tcp_module_t {
190190
typedef struct mca_btl_tcp_module_t mca_btl_tcp_module_t;
191191
extern mca_btl_tcp_module_t mca_btl_tcp_module;
192192

193-
#define CLOSE_THE_SOCKET(socket) {(void)shutdown(socket, SHUT_RDWR); (void)close(socket);}
193+
#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);}
194194

195195
/**
196196
* 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
@@ -684,6 +684,17 @@ void mca_btl_tcp_set_socket_options(int sd)
684684
strerror(opal_socket_errno), opal_socket_errno));
685685
}
686686
#endif
687+
#if defined(SO_NOSIGPIPE)
688+
/* Some BSD flavors generate EPIPE when we write to a disconnected peer. We need
689+
* the prevent this signal to be able to trap socket shutdown and cleanly release
690+
* the endpoint.
691+
*/
692+
int optval2 = 1;
693+
if(setsockopt(sd, SOL_SOCKET, SO_NOSIGPIPE, (char *)&optval2, sizeof(optval2)) < 0) {
694+
BTL_ERROR(("setsockopt(SO_NOSIGPIPE) failed: %s (%d)",
695+
strerror(opal_socket_errno), opal_socket_errno));
696+
}
697+
#endif
687698
}
688699

689700

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)