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:09:03 +0200
committerBjörn-Egil Dahlberg <[email protected]>2012-07-25 16:09:03 +0200
commit8ced228bed88f32a1f1b63ed5d37ada777e1de0b (patch)
tree2d2354960d1ecd793cc1bb332f99370e942f151a /lib/os_mon/c_src/win32sysinfo.c
parente6d1435935c5ca51d598c2839ade212490638e64 (diff)
parent9f6993fb41a8d14111325779c14968556b4f7f83 (diff)
downloadotp-8ced228bed88f32a1f1b63ed5d37ada777e1de0b.tar.gz
otp-8ced228bed88f32a1f1b63ed5d37ada777e1de0b.tar.bz2
otp-8ced228bed88f32a1f1b63ed5d37ada777e1de0b.zip
Merge branch 'maint'
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);
+}