summaryrefslogtreecommitdiff
path: root/server-tools/instance-manager/parse_output.cc
diff options
context:
space:
mode:
authorkonstantin@mysql.com <>2005-08-29 23:29:35 +0400
committerkonstantin@mysql.com <>2005-08-29 23:29:35 +0400
commit344144ad14f7a74fcda768caae446b4d0c511ce8 (patch)
treefdd882c833e7086e05fb1fcec50f3448f7bd7851 /server-tools/instance-manager/parse_output.cc
parent2f8a3bf747e3002c0d31af3710de4d48271c1bd0 (diff)
downloadmariadb-git-344144ad14f7a74fcda768caae446b4d0c511ce8.tar.gz
Cleanup the instance manager code.
Diffstat (limited to 'server-tools/instance-manager/parse_output.cc')
-rw-r--r--server-tools/instance-manager/parse_output.cc19
1 files changed, 11 insertions, 8 deletions
diff --git a/server-tools/instance-manager/parse_output.cc b/server-tools/instance-manager/parse_output.cc
index 98074c47d64..4ec9a71bfd2 100644
--- a/server-tools/instance-manager/parse_output.cc
+++ b/server-tools/instance-manager/parse_output.cc
@@ -43,8 +43,8 @@
if flag is GET_VALUE. Return the rest of the parsed string otherwise.
RETURN
- 0 - ok
- 1 - error occured
+ 0 - ok, the word has been found
+ 1 - error occured or the word is not found
*/
int parse_output_and_get_value(const char *command, const char *word,
@@ -56,9 +56,15 @@ int parse_output_and_get_value(const char *command, const char *word,
/* should be enough to store the string from the output */
enum { MAX_LINE_LEN= 512 };
char linebuf[MAX_LINE_LEN];
+ int rc= 1;
wordlen= strlen(word);
+ /*
+ Successful return of popen does not tell us whether the command has been
+ executed successfully: if the command was not found, we'll get EOF
+ when reading the output buffer below.
+ */
if (!(output= popen(command, "r")))
goto err;
@@ -95,10 +101,9 @@ int parse_output_and_get_value(const char *command, const char *word,
strmake(result, linep, found_word_len);
}
else /* currently there are only two options */
- {
strmake(result, linep, input_buffer_len - 1);
- }
- goto pclose;
+ rc= 0;
+ break;
}
}
@@ -106,9 +111,7 @@ pclose:
/* we are not interested in the termination status */
pclose(output);
- return 0;
-
err:
- return 1;
+ return rc;
}