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 | 898c43cef8d4e57740227743794700f0d7fa2ca2 (patch) | |
tree | bc380be180315112801db6f02c6cdc39bc4a8b72 | |
parent | 3642390b3c53f469916e02f7a1bebe4ebd0aeba3 (diff) | |
download | lightdm-remote-session-arctica-898c43cef8d4e57740227743794700f0d7fa2ca2.tar.gz lightdm-remote-session-arctica-898c43cef8d4e57740227743794700f0d7fa2ca2.tar.bz2 lightdm-remote-session-arctica-898c43cef8d4e57740227743794700f0d7fa2ca2.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; |