\hypertarget{session__dir_8h}{\section{orte/util/session\+\_\+dir.h File Reference}
\label{session__dir_8h}\index{orte/util/session\+\_\+dir.\+h@{orte/util/session\+\_\+dir.\+h}}
}


Find and/or create Open M\+P\+I session directory.  


{\ttfamily \#include \char`\"{}orte\+\_\+config.\+h\char`\"{}}\\*
{\ttfamily \#include \char`\"{}orte/types.\+h\char`\"{}}\\*
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
B\+E\+G\+I\+N\+\_\+\+C\+\_\+\+D\+E\+C\+L\+S O\+R\+T\+E\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C int \hyperlink{session__dir_8h_a90fdcaff533438ae740ee9798b3f74ff}{orte\+\_\+session\+\_\+dir} (bool create, char $\ast$prefix, char $\ast$hostid, char $\ast$batchid, \hyperlink{structorte__process__name__t}{orte\+\_\+process\+\_\+name\+\_\+t} $\ast$proc)
\item 
\hypertarget{session__dir_8h_a0771fd9b901477800aa82273441fe85c}{O\+R\+T\+E\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C int {\bfseries orte\+\_\+session\+\_\+dir\+\_\+get\+\_\+name} (char $\ast$$\ast$fulldirpath, char $\ast$$\ast$prfx, char $\ast$$\ast$frontend, char $\ast$hostid, char $\ast$batchid, \hyperlink{structorte__process__name__t}{orte\+\_\+process\+\_\+name\+\_\+t} $\ast$proc)}\label{session__dir_8h_a0771fd9b901477800aa82273441fe85c}

\item 
O\+R\+T\+E\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C int \hyperlink{session__dir_8h_afbe758c7c4c3a5587a3ad80983eeef87}{orte\+\_\+session\+\_\+dir\+\_\+finalize} (\hyperlink{structorte__process__name__t}{orte\+\_\+process\+\_\+name\+\_\+t} $\ast$proc)
\begin{DoxyCompactList}\small\item\em The \hyperlink{session__dir_8h_afbe758c7c4c3a5587a3ad80983eeef87}{orte\+\_\+session\+\_\+dir\+\_\+finalize()} function performs a cleanup of the session directory tree. \end{DoxyCompactList}\item 
O\+R\+T\+E\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C int \hyperlink{session__dir_8h_a6fd52c0c138436d78a19938dabf55da9}{orte\+\_\+session\+\_\+dir\+\_\+cleanup} (\hyperlink{orte_2include_2orte_2types_8h_addefe647f31eee13c7f756f0d959a99b}{orte\+\_\+jobid\+\_\+t} jobid)
\begin{DoxyCompactList}\small\item\em The \hyperlink{session__dir_8h_a6fd52c0c138436d78a19938dabf55da9}{orte\+\_\+session\+\_\+dir\+\_\+cleanup()} function performs a cleanup of the session directory tree when a job is aborted. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
Find and/or create Open M\+P\+I session directory. 

The \hyperlink{session__dir_8h_a90fdcaff533438ae740ee9798b3f74ff}{orte\+\_\+session\+\_\+dir()} function searches for a temporary directory that is used by the Open M\+P\+I system for storing system-\/critical information. For a given system and user, the function attempts to find (or create, if not found and create is requested) a directory that will be used to independently house information for multiple universes, as the user creates them. Thus, the function pursues a directory tree of the form\+:

\begin{DoxyParagraph}{{\itshape }\mbox{[}prefix-\/dir\mbox{]} An absolute path that identifies a temporary}
directory that is read-\/write-\/execute accessible to everyone. The function first checks to see if the user has specified the \mbox{[}prefix\mbox{]} directory on the command line. If so, then the function will use that \mbox{[}prefix\mbox{]} if the access permissions are correct, or will return an error condition if not -\/ the function will not search for alternative locations if the user provides the \mbox{[}prefix\mbox{]} name.
\end{DoxyParagraph}
\begin{DoxyParagraph}{If the \mbox{[}prefix\mbox{]} is not provided by the user, the function}
searches for a suitable directory in a specific order, taking the first option that meets the access permission requirement, using\+: (a) the \char`\"{}\+O\+M\+P\+I\+\_\+\+P\+R\+E\+F\+I\+X\+\_\+\+E\+N\+V\char`\"{} environment variable; (b) the \char`\"{}\+T\+M\+P\+D\+I\+R\char`\"{} environment variable; and (c) the \char`\"{}\+T\+M\+P\char`\"{} environment variabley. If none of those environmental variables have been defined and/or the function was unable to create a suitable directory within any of them, then the function tries to use a default location of \char`\"{}/tmp\char`\"{}, where the \char`\"{}/\char`\"{} represents the top-\/level directory of the local system. If none of these options are successful, the function returns an error code.
\end{DoxyParagraph}
\begin{DoxyParagraph}{{\itshape }\mbox{[}openmpi-\/sessions\mbox{]}-\/\mbox{[}user-\/id\mbox{]}@\mbox{[}host\mbox{]}\+:\mbox{[}batchid\mbox{]} This serves}
as a concentrator for all Open M\+P\+I session directories for this user on the local system. If it doesn't already exist, this directory is created with read-\/write-\/execute permissions exclusively restricted to the user. If it does exist, the access permissions are checked to ensure they are correct -\/ if not, the program attempts to correct them. If they can't' be changed to the correct values, an error condition is returned. The \mbox{[}host\mbox{]} and \mbox{[}batchid\mbox{]} fields are included to provide uniqueness on shared file systems and batch schedulers, respectively.
\end{DoxyParagraph}
\begin{DoxyParagraph}{Note\+: The \mbox{[}prefix\mbox{]}/openmpi-\/sessions-\/\mbox{[}user-\/id\mbox{]}@\mbox{[}host\mbox{]}\+:\mbox{[}batchid\mbox{]}}
directory is left on the system upon termination of an application and/or an Open M\+P\+I universe for future use by the user. Thus, when checking a potential location for the directory, the orte\+\_\+session\+\_\+tree\+\_\+init() function first checks to see if an appropriate directory already exists, and uses it if it does.
\end{DoxyParagraph}
\begin{DoxyParagraph}{{\itshape }\mbox{[}universe-\/name\mbox{]} A directory is created for the specified}
universe name. This is the directory that will be used to house all information relating to the specific universe. If the directory already exists (indicating that the user is joining an existing universe), then the function ensures that the user has exclusive read-\/write-\/execute permissions on the directory.
\end{DoxyParagraph}
\begin{DoxyParagraph}{{\itshape }\mbox{[}job\mbox{]} A directory is created for the specified job}
name. This will house all information relating to that specific job, including directories for each process within that job on this host.
\end{DoxyParagraph}
\begin{DoxyParagraph}{{\itshape }\mbox{[}process\mbox{]} A directory for the specific process, will house}
all information for that process.
\end{DoxyParagraph}
\begin{DoxyParagraph}{If {\ttfamily create} is {\ttfamily true}, the directory will be created and the}
proc\+\_\+info structure will be updated. If proc\+\_\+info is false, 
\end{DoxyParagraph}


\subsection{Function Documentation}
\hypertarget{session__dir_8h_a90fdcaff533438ae740ee9798b3f74ff}{\index{session\+\_\+dir.\+h@{session\+\_\+dir.\+h}!orte\+\_\+session\+\_\+dir@{orte\+\_\+session\+\_\+dir}}
\index{orte\+\_\+session\+\_\+dir@{orte\+\_\+session\+\_\+dir}!session\+\_\+dir.\+h@{session\+\_\+dir.\+h}}
\subsubsection[{orte\+\_\+session\+\_\+dir}]{\setlength{\rightskip}{0pt plus 5cm}B\+E\+G\+I\+N\+\_\+\+C\+\_\+\+D\+E\+C\+L\+S O\+R\+T\+E\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C int orte\+\_\+session\+\_\+dir (
\begin{DoxyParamCaption}
\item[{bool}]{create, }
\item[{char $\ast$}]{prefix, }
\item[{char $\ast$}]{hostid, }
\item[{char $\ast$}]{batchid, }
\item[{{\bf orte\+\_\+process\+\_\+name\+\_\+t} $\ast$}]{proc}
\end{DoxyParamCaption}
)}}\label{session__dir_8h_a90fdcaff533438ae740ee9798b3f74ff}

\begin{DoxyParams}{Parameters}
{\em create} & A boolean variable that indicates whether or not to create the specified directory. If set to \char`\"{}false\char`\"{}, the function only checks to see if an existing directory can be found. This is typically used to locate an already existing universe for reconnection purposes. If set to \char`\"{}true\char`\"{}, then the function creates the directory, if possible. \\
\hline
{\em prefix} & A string variable indicating where the user stipulated the directory should be found or placed. A value of \char`\"{}\+N\+U\+L\+L\char`\"{} indicates that the user specified no location -\/ hence, the function explores a range of \char`\"{}standard\char`\"{} locations. \\
\hline
{\em hostid} & Name of the host on which the session directory is being built. Used to build the name of the \char`\"{}openmpi-\/sessions-\/\mbox{[}user\mbox{]}@\mbox{[}host\mbox{]}\+:\mbox{[}batch\mbox{]}\char`\"{} branch of the directory tree. N\+U\+L\+L indicates that the nodename found in orte\+\_\+process\+\_\+info is to be used. \\
\hline
{\em batchid} & Batch job name, used in batch scheduling systems. N\+U\+L\+L indicates that the default of \char`\"{}0\char`\"{} is to be used. \\
\hline
{\em proc} & Pointer to a process name for which the session dir name is desired\\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em O\+R\+T\+E\+\_\+\+S\+U\+C\+C\+E\+S\+S} & The directory was found and/or created with the proper permissions. \\
\hline
{\em O\+M\+P\+I\+\_\+\+E\+R\+R\+O\+R} & The directory cannot be found (if create is \char`\"{}false\char`\"{}) or created (if create is \char`\"{}true\char`\"{}). \\
\hline
\end{DoxyRetVals}


References orte\+\_\+proc\+\_\+info\+\_\+t\+::job\+\_\+session\+\_\+dir, orte\+\_\+process\+\_\+name\+\_\+t\+::jobid, opal\+\_\+dirname(), opal\+\_\+os\+\_\+dirpath\+\_\+access(), opal\+\_\+output(), orte\+\_\+process\+\_\+info, orte\+\_\+proc\+\_\+info\+\_\+t\+::proc\+\_\+session\+\_\+dir, orte\+\_\+proc\+\_\+info\+\_\+t\+::tmpdir\+\_\+base, orte\+\_\+proc\+\_\+info\+\_\+t\+::top\+\_\+session\+\_\+dir, and orte\+\_\+process\+\_\+name\+\_\+t\+::vpid.



Referenced by orte\+\_\+ess\+\_\+base\+\_\+orted\+\_\+setup().

\hypertarget{session__dir_8h_a6fd52c0c138436d78a19938dabf55da9}{\index{session\+\_\+dir.\+h@{session\+\_\+dir.\+h}!orte\+\_\+session\+\_\+dir\+\_\+cleanup@{orte\+\_\+session\+\_\+dir\+\_\+cleanup}}
\index{orte\+\_\+session\+\_\+dir\+\_\+cleanup@{orte\+\_\+session\+\_\+dir\+\_\+cleanup}!session\+\_\+dir.\+h@{session\+\_\+dir.\+h}}
\subsubsection[{orte\+\_\+session\+\_\+dir\+\_\+cleanup}]{\setlength{\rightskip}{0pt plus 5cm}O\+R\+T\+E\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C int orte\+\_\+session\+\_\+dir\+\_\+cleanup (
\begin{DoxyParamCaption}
\item[{{\bf orte\+\_\+jobid\+\_\+t}}]{jobid}
\end{DoxyParamCaption}
)}}\label{session__dir_8h_a6fd52c0c138436d78a19938dabf55da9}


The \hyperlink{session__dir_8h_a6fd52c0c138436d78a19938dabf55da9}{orte\+\_\+session\+\_\+dir\+\_\+cleanup()} function performs a cleanup of the session directory tree when a job is aborted. 

It cleans up all process directories for a given job and then backs up the tree.


\begin{DoxyParams}{Parameters}
{\em jobid} & \\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em O\+M\+P\+I\+\_\+\+S\+U\+C\+C\+E\+S\+S} & If the directory tree is properly cleaned up. \\
\hline
{\em O\+M\+P\+I\+\_\+\+E\+R\+R\+O\+R} & If something prevents the tree from being properly cleaned up. \\
\hline
\end{DoxyRetVals}


References opal\+\_\+os\+\_\+dirpath\+\_\+destroy(), opal\+\_\+os\+\_\+dirpath\+\_\+is\+\_\+empty(), opal\+\_\+os\+\_\+path(), opal\+\_\+output(), O\+R\+T\+E\+\_\+\+P\+R\+O\+C\+\_\+\+M\+Y\+\_\+\+N\+A\+M\+E, orte\+\_\+process\+\_\+info, orte\+\_\+proc\+\_\+info\+\_\+t\+::tmpdir\+\_\+base, and orte\+\_\+proc\+\_\+info\+\_\+t\+::top\+\_\+session\+\_\+dir.

\hypertarget{session__dir_8h_afbe758c7c4c3a5587a3ad80983eeef87}{\index{session\+\_\+dir.\+h@{session\+\_\+dir.\+h}!orte\+\_\+session\+\_\+dir\+\_\+finalize@{orte\+\_\+session\+\_\+dir\+\_\+finalize}}
\index{orte\+\_\+session\+\_\+dir\+\_\+finalize@{orte\+\_\+session\+\_\+dir\+\_\+finalize}!session\+\_\+dir.\+h@{session\+\_\+dir.\+h}}
\subsubsection[{orte\+\_\+session\+\_\+dir\+\_\+finalize}]{\setlength{\rightskip}{0pt plus 5cm}O\+R\+T\+E\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C int orte\+\_\+session\+\_\+dir\+\_\+finalize (
\begin{DoxyParamCaption}
\item[{{\bf orte\+\_\+process\+\_\+name\+\_\+t} $\ast$}]{proc}
\end{DoxyParamCaption}
)}}\label{session__dir_8h_afbe758c7c4c3a5587a3ad80983eeef87}


The \hyperlink{session__dir_8h_afbe758c7c4c3a5587a3ad80983eeef87}{orte\+\_\+session\+\_\+dir\+\_\+finalize()} function performs a cleanup of the session directory tree. 

It first removes the session directory for the calling process. It then checks to see if the job-\/level session directory is now empty -\/ if so, it removes that level as well. Finally, it checks to see if the universe-\/level session directory is now empty -\/ if so, it also removes that level. This three-\/part \char`\"{}last-\/one-\/out\char`\"{} procedure ensures that the directory tree is properly removed if all processes and applications within a universe have completed.


\begin{DoxyParams}{Parameters}
{\em None} & \\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em O\+R\+T\+E\+\_\+\+S\+U\+C\+C\+E\+S\+S} & If the directory tree is properly cleaned up. \\
\hline
{\em O\+M\+P\+I\+\_\+\+E\+R\+R\+O\+R} & If something prevents the tree from being properly cleaned up. \\
\hline
\end{DoxyRetVals}


References orte\+\_\+process\+\_\+name\+\_\+t\+::jobid, opal\+\_\+os\+\_\+dirpath\+\_\+destroy(), opal\+\_\+os\+\_\+dirpath\+\_\+is\+\_\+empty(), opal\+\_\+os\+\_\+path(), opal\+\_\+output(), orte\+\_\+process\+\_\+info, orte\+\_\+proc\+\_\+info\+\_\+t\+::tmpdir\+\_\+base, orte\+\_\+proc\+\_\+info\+\_\+t\+::top\+\_\+session\+\_\+dir, and orte\+\_\+process\+\_\+name\+\_\+t\+::vpid.

