Index: /branches/rel_apv_10_7/usr/click/bin/backend/sys_cmd.c
===================================================================
--- /branches/rel_apv_10_7/usr/click/bin/backend/sys_cmd.c	(revision 39430)
+++ /branches/rel_apv_10_7/usr/click/bin/backend/sys_cmd.c	(working copy)
@@ -3297,6 +3297,9 @@
     char cmd[1024];
     char buffer[1024];
     size_t bytesRead;
+    time_t start = time(NULL);
+    int TIMEOUT = 60;
+    int got_login_response = 0;
 
     // check and delete file first
 
@@ -3322,13 +3325,11 @@
     system(cmd);
 
     printf("Your authentication code will expire in 60 seconds.\nPlease use the following information to sign in immediately.\n");
-    int count = 0;
 
     // read the tmp file from Mary
-    while(fp == NULL && count < 60) {
+    while(fp == NULL && (time(NULL) - start) < TIMEOUT) {
         fp = fopen("/tmp/login_msg.txt", "r");
         sleep(1);
-        count++;
     }
 
     if (fp != NULL) {
@@ -3346,12 +3347,14 @@
     }
 
     fp = NULL;
+    if ((time(NULL) - start) >= TIMEOUT) {
+        TIMEOUT += 5;
+    }
 
     // read the second file from Mary
-    while(fp == NULL && count < 60) {
+    while(fp == NULL && (time(NULL) - start) < TIMEOUT) {
         fp = fopen("/tmp/login_response.txt", "r");
         sleep(1);
-        count++;
     }
 
     if (fp != NULL) {
@@ -3368,13 +3371,17 @@
         while (fgets(buffer, sizeof(buffer), fp) != NULL) {
             printf("%s", buffer);
         }
-
+        got_login_response = 1;
         fclose(fp);
     }
 
     system("ps aux | grep 'az login' | grep -v grep | awk '{print $2}' | xargs kill -9");
     system("ps aux | grep 'python3 -sm azure.cli login' | grep -v grep | awk '{print $2}' | xargs kill -9");
     system("ps aux | grep 'python3 /ca/bin/azure/AZAuthManager.py -mode login' | grep -v grep | awk '{print $2}' | xargs kill -9");
+
+    if (!got_login_response) {
+        printf("Login attempt timed out. Please try 'cloud az login' to setup account again.\n");
+    }
 }
 
 
