Commit bc2b8129 bc2b8129d7ea25df488a988b486ec0fdd6a2a3d4 by Sergey Poznyakoff

(default_mail_start): Save mail spawn id in the global variable.

(default_mail_stop): Moved functionality from mail_exit
(mail_stop): Call default_mail_stop unless it has already
been called.
(mail_exit): Call mail_stop
1 parent 65de03bc
...@@ -51,6 +51,7 @@ proc default_mail_start {args} { ...@@ -51,6 +51,7 @@ proc default_mail_start {args} {
51 global MU_TOOL_FLAGS 51 global MU_TOOL_FLAGS
52 global mail_prompt 52 global mail_prompt
53 global expect_out 53 global expect_out
54 global mail_spawn_id
54 55
55 mu_version 56 mu_version
56 57
...@@ -69,8 +70,8 @@ proc default_mail_start {args} { ...@@ -69,8 +70,8 @@ proc default_mail_start {args} {
69 set mail_cmd "$MU_TOOL $sw" 70 set mail_cmd "$MU_TOOL $sw"
70 verbose "Spawning $mail_cmd" 71 verbose "Spawning $mail_cmd"
71 72
72 set res [remote_spawn host $mail_cmd] 73 set mail_spawn_id [remote_spawn host $mail_cmd]
73 if { $res < 0 || $res == "" } { 74 if { $mail_spawn_id < 0 || $mail_spawn_id == "" } {
74 perror "Spawning $mail_cmd failed." 75 perror "Spawning $mail_cmd failed."
75 return 1; 76 return 1;
76 } 77 }
...@@ -88,9 +89,9 @@ proc default_mail_start {args} { ...@@ -88,9 +89,9 @@ proc default_mail_start {args} {
88 } 89 }
89 90
90 proc default_mail_stop {} { 91 proc default_mail_stop {} {
91
92 verbose "Stopping mail" 92 verbose "Stopping mail"
93 93 mail_command "exit"
94 remote_close host
94 } 95 }
95 96
96 proc mail_start {args} { 97 proc mail_start {args} {
...@@ -113,7 +114,11 @@ proc mail_start {args} { ...@@ -113,7 +114,11 @@ proc mail_start {args} {
113 } 114 }
114 115
115 proc mail_stop {} { 116 proc mail_stop {} {
116 return [default_mail_stop]; 117 global mail_spawn_id
118 if {[info exists mail_spawn_id] && $mail_spawn_id > 0} {
119 default_mail_stop
120 unset mail_spawn_id
121 }
117 } 122 }
118 123
119 ## 124 ##
...@@ -127,9 +132,7 @@ proc mail_command { cmd } { ...@@ -127,9 +132,7 @@ proc mail_command { cmd } {
127 } 132 }
128 133
129 proc mail_exit {} { 134 proc mail_exit {} {
130 set res [mail_send "exit\n"] 135 mail_stop
131 sleep 5
132 return res
133 } 136 }
134 137
135 # mail_test [-message MESSAGE][-default (FAIL|XFAIL)][-noprompt] 138 # mail_test [-message MESSAGE][-default (FAIL|XFAIL)][-noprompt]
......