aboutsummaryrefslogtreecommitdiffstats
path: root/lib/os_mon/c_src/win32sysinfo.c
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2012-07-24 17:03:01 +0200
committerBjörn-Egil Dahlberg <[email protected]>2012-07-24 17:14:16 +0200
commit0da1a7be25ec7ae3a185dd69d3e3d6e1f5401dbb (patch)
tree36721a788d0b7d985634042e88deb2f79f232047 /lib/os_mon/c_src/win32sysinfo.c
parent92eb89bd630e822cfc93a07dad7d6c7a25f45d63 (diff)
downloadotp-0da1a7be25ec7ae3a185dd69d3e3d6e1f5401dbb.tar.gz
otp-0da1a7be25ec7ae3a185dd69d3e3d6e1f5401dbb.tar.bz2
otp-0da1a7be25ec7ae3a185dd69d3e3d6e1f5401dbb.zip
os_mon: Elucidate port program error messages
Try to avoid confusion of the message 'Erlang has closed' by clarifying that the message is sent from os_mon port programs.
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);
+}