3030#include "opal/util/output.h"
3131#include "opal/dss/dss.h"
3232#include "opal/mca/event/event.h"
33+ #include "opal/mca/pmix/pmix.h"
3334
3435#include "orte/mca/errmgr/errmgr.h"
3536#include "orte/mca/rml/rml.h"
@@ -602,11 +603,23 @@ int orte_show_help(const char *filename, const char *topic,
602603 return rc ;
603604}
604605
606+ static void cbfunc (int status , void * cbdata )
607+ {
608+ volatile bool * active = (volatile bool * )cbdata ;
609+ * active = false;
610+ }
611+
605612int orte_show_help_norender (const char * filename , const char * topic ,
606613 bool want_error_header , const char * output )
607614{
608615 int rc = ORTE_SUCCESS ;
609616 int8_t have_output = 1 ;
617+ opal_buffer_t * buf ;
618+ bool am_inside = false;
619+ opal_list_t info ;
620+ opal_value_t * kv ;
621+ volatile bool active ;
622+ struct timespec tp ;
610623
611624 if (!ready ) {
612625 /* if we are finalizing, then we have no way to process
@@ -628,39 +641,44 @@ int orte_show_help_norender(const char *filename, const char *topic,
628641 * mode, then all we can do is process this locally
629642 */
630643 if (ORTE_PROC_IS_HNP || ORTE_PROC_IS_TOOL ||
631- orte_standalone_operation ||
632- NULL == orte_rml .send_buffer_nb ||
633- NULL == orte_routed .get_route ||
634- NULL == orte_process_info .my_hnp_uri ) {
644+ orte_standalone_operation ) {
635645 rc = show_help (filename , topic , output , ORTE_PROC_MY_NAME );
646+ goto CLEANUP ;
647+ } else if (ORTE_PROC_IS_DAEMON ) {
648+ if (NULL == orte_rml .send_buffer_nb ||
649+ NULL == orte_routed .get_route ||
650+ NULL == orte_process_info .my_hnp_uri ) {
651+ rc = show_help (filename , topic , output , ORTE_PROC_MY_NAME );
652+ goto CLEANUP ;
653+ }
636654 }
637655
638656 /* otherwise, we relay the output message to
639657 * the HNP for processing
640658 */
641- else {
642- opal_buffer_t * buf ;
643- static bool am_inside = false;
644659
645- /* JMS Note that we *may* have a recursion situation here where
646- the RML could call show_help. Need to think about this
647- properly, but put a safeguard in here for sure for the time
648- being. */
649- if (am_inside ) {
650- rc = show_help (filename , topic , output , ORTE_PROC_MY_NAME );
651- } else {
652- am_inside = true;
653-
654- /* build the message to the HNP */
655- buf = OBJ_NEW (opal_buffer_t );
656- /* pack the filename of the show_help text file */
657- opal_dss .pack (buf , & filename , 1 , OPAL_STRING );
658- /* pack the topic tag */
659- opal_dss .pack (buf , & topic , 1 , OPAL_STRING );
660- /* pack the flag that we have a string */
661- opal_dss .pack (buf , & have_output , 1 , OPAL_INT8 );
662- /* pack the resulting string */
663- opal_dss .pack (buf , & output , 1 , OPAL_STRING );
660+ /* JMS Note that we *may* have a recursion situation here where
661+ the RML could call show_help. Need to think about this
662+ properly, but put a safeguard in here for sure for the time
663+ being. */
664+ if (am_inside ) {
665+ rc = show_help (filename , topic , output , ORTE_PROC_MY_NAME );
666+ } else {
667+ am_inside = true;
668+
669+ /* build the message to the HNP */
670+ buf = OBJ_NEW (opal_buffer_t );
671+ /* pack the filename of the show_help text file */
672+ opal_dss .pack (buf , & filename , 1 , OPAL_STRING );
673+ /* pack the topic tag */
674+ opal_dss .pack (buf , & topic , 1 , OPAL_STRING );
675+ /* pack the flag that we have a string */
676+ opal_dss .pack (buf , & have_output , 1 , OPAL_INT8 );
677+ /* pack the resulting string */
678+ opal_dss .pack (buf , & output , 1 , OPAL_STRING );
679+
680+ /* if we are a daemon, then send it via RML to the HNP */
681+ if (ORTE_PROC_IS_DAEMON ) {
664682 /* send it to the HNP */
665683 if (ORTE_SUCCESS != (rc = orte_rml .send_buffer_nb (ORTE_PROC_MY_HNP , buf ,
666684 ORTE_RML_TAG_SHOW_HELP ,
@@ -672,8 +690,33 @@ int orte_show_help_norender(const char *filename, const char *topic,
672690 } else {
673691 rc = ORTE_SUCCESS ;
674692 }
675- am_inside = false;
693+ } else {
694+ /* if we are not a daemon (i.e., we are an app) and if PMIx
695+ * support for "log" is available, then use that channel */
696+ if (NULL != opal_pmix .log ) {
697+ OBJ_CONSTRUCT (& info , opal_list_t );
698+ kv = OBJ_NEW (opal_value_t ),
699+ kv -> key = strdup (OPAL_PMIX_LOG_STDERR );
700+ kv -> type = OPAL_BYTE_OBJECT ;
701+ opal_dss .unload (buf , (void * * )& kv -> data .bo .bytes , & kv -> data .bo .size );
702+ opal_list_append (& info , & kv -> super );
703+ active = true;
704+ tp .tv_sec = 0 ;
705+ tp .tv_nsec = 1000000 ;
706+ opal_pmix .log (& info , cbfunc , (void * )& active );
707+ while (active ) {
708+ nanosleep (& tp , NULL );
709+ }
710+ OBJ_RELEASE (buf );
711+ kv -> data .bo .bytes = NULL ;
712+ OPAL_LIST_DESTRUCT (& info );
713+ rc = ORTE_SUCCESS ;
714+ goto CLEANUP ;
715+ } else {
716+ rc = show_help (filename , topic , output , ORTE_PROC_MY_NAME );
717+ }
676718 }
719+ am_inside = false;
677720 }
678721
679722CLEANUP :
0 commit comments