Changes to debug 'os_con_pid empty' issue.

Change-Id: I5078636672195a1afcbbc0b7a05b44929cfa4768
Signed-off-by: Michael Walsh <micwalsh@us.ibm.com>
diff --git a/lib/utils.robot b/lib/utils.robot
index ca1376f..f25c82c 100755
--- a/lib/utils.robot
+++ b/lib/utils.robot
@@ -520,7 +520,12 @@
     [Return]  ${cmd_buf}
 
 Get SOL Console Pid
-    [Documentation]  Get the pid of the active sol conole job.
+    [Documentation]  Get the pid of the active SOL console job.
+    [Arguments]  ${expect_running}=${0}
+
+    # Description of argument(s):
+    # expect_running  If set and if no SOL console job is found, print debug
+    #                 info and fail.
 
     # Find the pid of the active system console logging session (if any).
     ${search_string}=  Create OS Console Command String
@@ -528,15 +533,22 @@
     # replace them in our search string with the regexes to indicate that they
     # are optional.
     ${search_string}=  Replace String  ${search_string}  "  ["]?
-    ${cmd_buf}=  Catenate  echo $(ps awwo user,pid,cmd | egrep
-    ...  '${search_string}' | egrep -v grep | cut -c10-14)
+    ${ps_cmd}=  Catenate  ps axwwo user,pid,cmd
+    ${cmd_buf}=  Catenate  echo $(${ps_cmd} | egrep '${search_string}' |
+    ...  egrep -v grep | cut -c10-14)
     Rdpissuing  ${cmd_buf}
     ${rc}  ${os_con_pid}=  Run And Return Rc And Output  ${cmd_buf}
     Rdpvars  os_con_pid
     # If rc is not zero it just means that there is no OS Console process
     # running.
 
-    [Return]  ${os_con_pid}
+    Return From Keyword If  '${os_con_pid}' != '${EMPTY}'  ${os_con_pid}
+    Return From Keyword If  '${expect_running}' == '${0}'  ${os_con_pid}
+
+    Cmd Fnc  cat ${log_file_path} ; echo ; ${ps_cmd}  quiet=${0}
+    ...  print_output=${1}  show_err=${1}
+
+    Should Not Be Empty  ${os_con_pid}
 
 
 Stop SOL Console Logging
@@ -620,13 +632,12 @@
     # non-zero return code or any output.
     Should Be Equal  ${rc}  ${0}
 
-    Sleep  1
-    ${os_con_pid}=  Get SOL Console Pid
-
-    Should Not Be Empty  ${os_con_pid}
+    Wait Until Keyword Succeeds  10 seconds  0 seconds
+    ...   Get SOL Console Pid  ${1}
 
     [Return]  ${log_output}
 
+
 Get Time Stamp
     [Documentation]     Get the current time stamp data
     ${cur_time}=    Get Current Date   result_format=%Y%m%d%H%M%S%f