diff --git a/orte/mca/oob/tcp/oob_tcp_component.c b/orte/mca/oob/tcp/oob_tcp_component.c index d3a58f43a1..d6ce0bc341 100644 --- a/orte/mca/oob/tcp/oob_tcp_component.c +++ b/orte/mca/oob/tcp/oob_tcp_component.c @@ -661,7 +661,7 @@ static void component_shutdown(void) if (ORTE_PROC_IS_HNP && mca_oob_tcp_component.listen_thread_active) { mca_oob_tcp_component.listen_thread_active = false; /* tell the thread to exit */ - write(mca_oob_tcp_component.stop_thread, &i, sizeof(int)); + write(mca_oob_tcp_component.stop_thread[1], &i, sizeof(int)); opal_thread_join(&mca_oob_tcp_component.listen_thread, NULL); } diff --git a/orte/mca/oob/tcp/oob_tcp_component.h b/orte/mca/oob/tcp/oob_tcp_component.h index 51ed452603..1759217c8b 100644 --- a/orte/mca/oob/tcp/oob_tcp_component.h +++ b/orte/mca/oob/tcp/oob_tcp_component.h @@ -78,7 +78,7 @@ typedef struct { opal_thread_t listen_thread; /**< handle to the listening thread */ bool listen_thread_active; struct timeval listen_thread_tv; /**< Timeout when using listen thread */ - int stop_thread; /**< file descriptor used to exit the listen thread */ + int stop_thread[2]; /**< pipe used to exit the listen thread */ /* peers available via this transport - the index is the process name, * and the pointer returned is the pointer to the last module that diff --git a/orte/mca/oob/tcp/oob_tcp_listener.c b/orte/mca/oob/tcp/oob_tcp_listener.c index 88e3fc81fa..5a500316aa 100644 --- a/orte/mca/oob/tcp/oob_tcp_listener.c +++ b/orte/mca/oob/tcp/oob_tcp_listener.c @@ -125,7 +125,10 @@ int orte_oob_tcp_start_listening(void) * harvest connection requests as rapidly as possible */ if (ORTE_PROC_IS_HNP) { - mca_oob_tcp_component.stop_thread = open("/dev/null", O_RDWR); + if (0 > pipe(mca_oob_tcp_component.stop_thread)) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } mca_oob_tcp_component.listen_thread_active = true; mca_oob_tcp_component.listen_thread.t_run = listen_thread; mca_oob_tcp_component.listen_thread.t_arg = NULL; @@ -642,8 +645,8 @@ static void* listen_thread(opal_object_t *obj) max = (listener->sd > max) ? listener->sd : max; } /* add the stop_thread fd */ - FD_SET(mca_oob_tcp_component.stop_thread, &readfds); - max = (mca_oob_tcp_component.stop_thread > max) ? mca_oob_tcp_component.stop_thread : max; + FD_SET(mca_oob_tcp_component.stop_thread[0], &readfds); + max = (mca_oob_tcp_component.stop_thread[0] > max) ? mca_oob_tcp_component.stop_thread[0] : max; /* set timeout interval */ timeout.tv_sec = mca_oob_tcp_component.listen_thread_tv.tv_sec; @@ -655,6 +658,8 @@ static void* listen_thread(opal_object_t *obj) rc = select(max + 1, &readfds, NULL, NULL, &timeout); if (!mca_oob_tcp_component.listen_thread_active) { /* we've been asked to terminate */ + close(mca_oob_tcp_component.stop_thread[0]); + close(mca_oob_tcp_component.stop_thread[1]); return NULL; } if (rc < 0) {