aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2012-08-29 16:34:01 -0500
committerTed Gould <ted@gould.cx>2012-08-29 16:34:01 -0500
commitdd7dda9f5b5626ef84510f317ea2929744680557 (patch)
treebc380be180315112801db6f02c6cdc39bc4a8b72
parentbbc1c93c14f71acae5d3f1efea17a6c24e244296 (diff)
downloadlightdm-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.c7
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;