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
commit898c43cef8d4e57740227743794700f0d7fa2ca2 (patch)
treebc380be180315112801db6f02c6cdc39bc4a8b72
parent3642390b3c53f469916e02f7a1bebe4ebd0aeba3 (diff)
downloadlightdm-remote-session-x2go-898c43cef8d4e57740227743794700f0d7fa2ca2.tar.gz
lightdm-remote-session-x2go-898c43cef8d4e57740227743794700f0d7fa2ca2.tar.bz2
lightdm-remote-session-x2go-898c43cef8d4e57740227743794700f0d7fa2ca2.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;