@@ -118,6 +118,7 @@ static pmix_status_t setup_fork(const pmix_proc_t *proc, char ***env);
118118 .disable_ipv6_family = true,
119119 .session_filename = NULL ,
120120 .nspace_filename = NULL ,
121+ .pid_filename = NULL ,
121122 .system_filename = NULL ,
122123 .rendezvous_filename = NULL ,
123124 .wait_to_connect = 4 ,
@@ -298,6 +299,10 @@ pmix_status_t component_close(void)
298299 unlink (mca_ptl_tcp_component .nspace_filename );
299300 free (mca_ptl_tcp_component .nspace_filename );
300301 }
302+ if (NULL != mca_ptl_tcp_component .pid_filename ) {
303+ unlink (mca_ptl_tcp_component .pid_filename );
304+ free (mca_ptl_tcp_component .pid_filename );
305+ }
301306 if (NULL != mca_ptl_tcp_component .rendezvous_filename ) {
302307 unlink (mca_ptl_tcp_component .rendezvous_filename );
303308 free (mca_ptl_tcp_component .rendezvous_filename );
@@ -751,10 +756,10 @@ static pmix_status_t setup_listener(pmix_info_t info[], size_t ninfo,
751756 FILE * fp ;
752757 pid_t mypid ;
753758
754- /* first output to a file based on pid */
759+ /* first output to a std file */
755760 mypid = getpid ();
756- if (0 > asprintf (& mca_ptl_tcp_component .session_filename , "%s/pmix.%s.tool.%d " ,
757- mca_ptl_tcp_component .session_tmpdir , myhost , mypid )) {
761+ if (0 > asprintf (& mca_ptl_tcp_component .session_filename , "%s/pmix.%s.tool" ,
762+ mca_ptl_tcp_component .session_tmpdir , myhost )) {
758763 CLOSE_THE_SOCKET (lt -> socket );
759764 goto sockerror ;
760765 }
@@ -785,6 +790,40 @@ static pmix_status_t setup_listener(pmix_info_t info[], size_t ninfo,
785790 goto sockerror ;
786791 }
787792
793+ /* now output to a file based on pid */
794+ mypid = getpid ();
795+ if (0 > asprintf (& mca_ptl_tcp_component .pid_filename , "%s/pmix.%s.tool.%d" ,
796+ mca_ptl_tcp_component .session_tmpdir , myhost , mypid )) {
797+ CLOSE_THE_SOCKET (lt -> socket );
798+ goto sockerror ;
799+ }
800+ pmix_output_verbose (2 , pmix_ptl_base_framework .framework_output ,
801+ "WRITING TOOL FILE %s" ,
802+ mca_ptl_tcp_component .pid_filename );
803+ fp = fopen (mca_ptl_tcp_component .pid_filename , "w" );
804+ if (NULL == fp ) {
805+ pmix_output (0 , "Impossible to open the file %s in write mode\n" , mca_ptl_tcp_component .pid_filename );
806+ PMIX_ERROR_LOG (PMIX_ERR_FILE_OPEN_FAILURE );
807+ CLOSE_THE_SOCKET (lt -> socket );
808+ free (mca_ptl_tcp_component .pid_filename );
809+ mca_ptl_tcp_component .pid_filename = NULL ;
810+ goto sockerror ;
811+ }
812+
813+ /* output my URI */
814+ fprintf (fp , "%s\n" , lt -> uri );
815+ /* add a flag that indicates we accept v2.1 protocols */
816+ fprintf (fp , "%s\n" , PMIX_VERSION );
817+ fclose (fp );
818+ /* set the file mode */
819+ if (0 != chmod (mca_ptl_tcp_component .pid_filename , S_IRUSR | S_IWUSR | S_IRGRP )) {
820+ PMIX_ERROR_LOG (PMIX_ERR_FILE_OPEN_FAILURE );
821+ CLOSE_THE_SOCKET (lt -> socket );
822+ free (mca_ptl_tcp_component .pid_filename );
823+ mca_ptl_tcp_component .pid_filename = NULL ;
824+ goto sockerror ;
825+ }
826+
788827 /* now output it into a file based on my nspace */
789828
790829 if (0 > asprintf (& mca_ptl_tcp_component .nspace_filename , "%s/pmix.%s.tool.%s" ,
0 commit comments