Index: src/plugins/console.c =================================================================== --- src/plugins/console.c (revision 1) +++ src/plugins/console.c (revision 200) @@ -14,6 +14,7 @@ #include #endif #include // stdin, fgets +#include "../common/showmsg.h" //showerror #define INPUT_BUFSIZE 4096 #define INPUT_INVALID 0 @@ -277,8 +278,10 @@ { if( state == INPUT_READY && input_getstate() == INPUT_READING ) {// send data from the worker to the main process - write(buf.data_pipe[PIPE_WRITE], &buf.len, sizeof(buf.len)); - write(buf.data_pipe[PIPE_WRITE], &buf.arr, buf.len); + if (write(buf.data_pipe[PIPE_WRITE], &buf.len, sizeof(buf.len)) == -1) + ShowError("console.c input_setstate writting1 error"); + if (write(buf.data_pipe[PIPE_WRITE], &buf.arr, buf.len) == -1) + ShowError("console.c input_setstate writting2 error"); } else if( state == INPUT_WAITING ){ if( buf.close_unused_flag == 0 ) {// close unused pipe sides in the main process @@ -287,7 +290,8 @@ buf.close_unused_flag = 1; } // send the next state - write(buf.state_pipe[PIPE_WRITE], &state, sizeof(state)); + if (write(buf.state_pipe[PIPE_WRITE], &state, sizeof(state)) == -1) + ShowError("console.c input_setstate writting3 error"); } else if( state == INPUT_READING ){ if( buf.close_unused_flag == 0 ) {// close unused pipe sides in the worker process @@ -297,7 +301,8 @@ } } else if( state == INPUT_CLOSED ) {// send next state to the worker and close the pipes - write(buf.state_pipe[PIPE_WRITE], &state, sizeof(state)); + if (write(buf.state_pipe[PIPE_WRITE], &state, sizeof(state)) == -1) + ShowError("console.c input_setstate writting4 error"); close(buf.data_pipe[PIPE_WRITE]); close(buf.data_pipe[PIPE_READ]); close(buf.state_pipe[PIPE_WRITE]); @@ -339,8 +344,10 @@ hasData = ( poll(&fds,1,0) > 0 ); if( hasData ) {// read the data from the pipe - read(buf.data_pipe[PIPE_READ], &buf.len, sizeof(buf.len)); - read(buf.data_pipe[PIPE_READ], buf.arr, buf.len); + if (read(buf.data_pipe[PIPE_READ], &buf.len, sizeof(buf.len)) == -1); + ShowError("console.c input_hasdata() reading1 error"); + if (read(buf.data_pipe[PIPE_READ], buf.arr, buf.len) == -1); + ShowError("console.c input_hasdata() reading2 error"); input_setstate(INPUT_READY); } @@ -405,7 +412,8 @@ {// get input input_setstate(INPUT_READING); buf.arr[0] = '\0'; - fgets(buf.arr, INPUT_BUFSIZE, stdin); + if (fgets(buf.arr, INPUT_BUFSIZE, stdin) == NULL) + ShowError("console.c WORKER_FUNC_START(getinput) error"); buf.len = strlen(buf.arr); input_setstate(INPUT_READY); }