aboutsummaryrefslogtreecommitdiffstats
path: root/lib/os_mon/c_src/win32sysinfo.c
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2012-07-25 16:08:41 +0200
committerBjörn-Egil Dahlberg <[email protected]>2012-07-25 16:08:41 +0200
commit9f6993fb41a8d14111325779c14968556b4f7f83 (patch)
tree8f42ab42bc24104d17955d61940111ed2fa36033 /lib/os_mon/c_src/win32sysinfo.c
parentc0cb221de152593a36c4468e0f46abd0b37afae2 (diff)
parent0da1a7be25ec7ae3a185dd69d3e3d6e1f5401dbb (diff)
downloadotp-9f6993fb41a8d14111325779c14968556b4f7f83.tar.gz
otp-9f6993fb41a8d14111325779c14968556b4f7f83.tar.bz2
otp-9f6993fb41a8d14111325779c14968556b4f7f83.zip
Merge branch 'egil/change-os_mon-ports-error-messages/OTP-10161' into maint
* egil/change-os_mon-ports-error-messages/OTP-10161: os_mon: Elucidate port program error messages
Diffstat (limited to 'lib/os_mon/c_src/win32sysinfo.c')
-rw-r--r--lib/os_mon/c_src/win32sysinfo.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/lib/os_mon/c_src/win32sysinfo.c b/lib/os_mon/c_src/win32sysinfo.c
index 2a155aae87..9d4587393f 100644
--- a/lib/os_mon/c_src/win32sysinfo.c
+++ b/lib/os_mon/c_src/win32sysinfo.c
@@ -89,6 +89,7 @@ typedef BOOL (WINAPI *tfpGetDiskFreeSpaceEx)(LPCTSTR, PULARGE_INTEGER,PULARGE_IN
static tfpGetDiskFreeSpaceEx fpGetDiskFreeSpaceEx;
+static void print_error(const char *msg);
static void
return_answer(char* value)
{
@@ -98,7 +99,7 @@ return_answer(char* value)
res = write(1,(char*) &bytes,1);
if (res != 1) {
- fprintf(stderr,"win32sysinfo:Error writing to pipe");
+ print_error("Error writing to pipe");
exit(1);
}
@@ -107,9 +108,8 @@ return_answer(char* value)
while (left > 0)
{
res = write(1, value+bytes-left, left);
- if (res <= 0)
- {
- fprintf(stderr,"win32sysinfo:Error writing to pipe");
+ if (res <= 0) {
+ print_error("Error writing to pipe");
exit(1);
}
left -= res;
@@ -248,7 +248,6 @@ message_loop()
char cmd[512];
int res;
- fprintf(stderr,"in message_loop\n");
/* Startup ACK. */
return_answer(OK);
while (1)
@@ -257,12 +256,12 @@ message_loop()
* Wait for command from Erlang
*/
if ((res = read(0, &cmdLen, 1)) < 0) {
- fprintf(stderr,"win32sysinfo:Error reading from Erlang.");
+ print_error("Error reading from Erlang");
return;
}
if (res != 1){ /* Exactly one byte read ? */
- fprintf(stderr,"win32sysinfo:Erlang has closed.");
+ print_error("Erlang has closed");
return;
}
if ((res = read(0, &cmd, cmdLen)) == cmdLen){
@@ -291,11 +290,11 @@ message_loop()
return_answer("xEND");
}
else if (res == 0) {
- fprintf(stderr,"win32sysinfo:Erlang has closed.");
+ print_error("Erlang has closed");
return;
}
else {
- fprintf(stderr,"win32sysinfo:Error reading from Erlang.");
+ print_error("Error reading from Erlang");
return;
}
}
@@ -309,10 +308,9 @@ int main(int argc, char ** argv){
message_loop();
return 0;
}
-
-
-
-
-
-
-
+static void
+print_error(const char *msg) {
+ /* try to use one write only */
+ fprintf(stderr, "[os_mon] win32 supervisor port (win32sysinfo): %s\r\n", msg);
+ fflush(stderr);
+}