@@ -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 ,
@@ -306,6 +307,10 @@ pmix_status_t component_close(void)
306307 unlink (mca_ptl_tcp_component .nspace_filename );
307308 free (mca_ptl_tcp_component .nspace_filename );
308309 }
310+ if (NULL != mca_ptl_tcp_component .pid_filename ) {
311+ unlink (mca_ptl_tcp_component .pid_filename );
312+ free (mca_ptl_tcp_component .pid_filename );
313+ }
309314 if (NULL != mca_ptl_tcp_component .rendezvous_filename ) {
310315 unlink (mca_ptl_tcp_component .rendezvous_filename );
311316 free (mca_ptl_tcp_component .rendezvous_filename );
@@ -779,10 +784,10 @@ static pmix_status_t setup_listener(pmix_info_t info[], size_t ninfo,
779784 FILE * fp ;
780785 pid_t mypid ;
781786
782- /* first output to a file based on pid */
787+ /* first output to a std file */
783788 mypid = getpid ();
784- if (0 > asprintf (& mca_ptl_tcp_component .session_filename , "%s/pmix.%s.tool.%d " ,
785- mca_ptl_tcp_component .session_tmpdir , myhost , mypid )) {
789+ if (0 > asprintf (& mca_ptl_tcp_component .session_filename , "%s/pmix.%s.tool" ,
790+ mca_ptl_tcp_component .session_tmpdir , myhost )) {
786791 CLOSE_THE_SOCKET (lt -> socket );
787792 goto sockerror ;
788793 }
@@ -813,6 +818,40 @@ static pmix_status_t setup_listener(pmix_info_t info[], size_t ninfo,
813818 goto sockerror ;
814819 }
815820
821+ /* now output to a file based on pid */
822+ mypid = getpid ();
823+ if (0 > asprintf (& mca_ptl_tcp_component .pid_filename , "%s/pmix.%s.tool.%d" ,
824+ mca_ptl_tcp_component .session_tmpdir , myhost , mypid )) {
825+ CLOSE_THE_SOCKET (lt -> socket );
826+ goto sockerror ;
827+ }
828+ pmix_output_verbose (2 , pmix_ptl_base_framework .framework_output ,
829+ "WRITING TOOL FILE %s" ,
830+ mca_ptl_tcp_component .pid_filename );
831+ fp = fopen (mca_ptl_tcp_component .pid_filename , "w" );
832+ if (NULL == fp ) {
833+ pmix_output (0 , "Impossible to open the file %s in write mode\n" , mca_ptl_tcp_component .pid_filename );
834+ PMIX_ERROR_LOG (PMIX_ERR_FILE_OPEN_FAILURE );
835+ CLOSE_THE_SOCKET (lt -> socket );
836+ free (mca_ptl_tcp_component .pid_filename );
837+ mca_ptl_tcp_component .pid_filename = NULL ;
838+ goto sockerror ;
839+ }
840+
841+ /* output my URI */
842+ fprintf (fp , "%s\n" , lt -> uri );
843+ /* add a flag that indicates we accept v2.1 protocols */
844+ fprintf (fp , "%s\n" , PMIX_VERSION );
845+ fclose (fp );
846+ /* set the file mode */
847+ if (0 != chmod (mca_ptl_tcp_component .pid_filename , S_IRUSR | S_IWUSR | S_IRGRP )) {
848+ PMIX_ERROR_LOG (PMIX_ERR_FILE_OPEN_FAILURE );
849+ CLOSE_THE_SOCKET (lt -> socket );
850+ free (mca_ptl_tcp_component .pid_filename );
851+ mca_ptl_tcp_component .pid_filename = NULL ;
852+ goto sockerror ;
853+ }
854+
816855 /* now output it into a file based on my nspace */
817856
818857 if (0 > asprintf (& mca_ptl_tcp_component .nspace_filename , "%s/pmix.%s.tool.%s" ,
0 commit comments