diff options
author | Ted Gould <ted@gould.cx> | 2012-08-29 16:34:01 -0500 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2012-08-29 16:34:01 -0500 |
commit | dd7dda9f5b5626ef84510f317ea2929744680557 (patch) | |
tree | bc380be180315112801db6f02c6cdc39bc4a8b72 | |
parent | bbc1c93c14f71acae5d3f1efea17a6c24e244296 (diff) | |
download | lightdm-remote-session-freerdp2-dd7dda9f5b5626ef84510f317ea2929744680557.tar.gz lightdm-remote-session-freerdp2-dd7dda9f5b5626ef84510f317ea2929744680557.tar.bz2 lightdm-remote-session-freerdp2-dd7dda9f5b5626ef84510f317ea2929744680557.zip |
Checking the return values on read and write better
-rw-r--r-- | socket-sucker.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/socket-sucker.c b/socket-sucker.c index d711cb0..54aee32 100644 --- a/socket-sucker.c +++ b/socket-sucker.c @@ -62,11 +62,14 @@ main (int argc, char * argv[]) int out = 0; in = read(socket_fd, buffer, BUFFER_SIZE); - out = write(1, buffer, in); + + if (in > 0) { + out = write(1, buffer, in); + } close(socket_fd); - if (in == 0) { + if (in > 0 && out > 0) { return 0; } else { return -1; |