diff options
author | Amit Shah <amit.shah@redhat.com> | 2010-04-01 14:55:46 +0530 |
---|---|---|
committer | Amit Shah <amit.shah@redhat.com> | 2010-04-06 20:00:32 +0530 |
commit | 873d4e83413cbd1be336c7157d28f763f8e7208e (patch) | |
tree | 8287840055b975299ff58e0ee6b40f7086417a4f /auto-virtserial-guest.c | |
parent | 3e99892230d186252a7adedefa31d7e0d844a9cf (diff) | |
download | test-virtserial-873d4e83413cbd1be336c7157d28f763f8e7208e.tar.gz test-virtserial-873d4e83413cbd1be336c7157d28f763f8e7208e.tar.xz test-virtserial-873d4e83413cbd1be336c7157d28f763f8e7208e.zip |
guest, test-virtserial: Fix fcntl usage
While setting or clearing the O_NONBLOCK flag for file descriptors, we
were trampling on the other flags.
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Diffstat (limited to 'auto-virtserial-guest.c')
-rw-r--r-- | auto-virtserial-guest.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/auto-virtserial-guest.c b/auto-virtserial-guest.c index ce64ebc..6776874 100644 --- a/auto-virtserial-guest.c +++ b/auto-virtserial-guest.c @@ -142,9 +142,15 @@ static int set_port_nonblocking(int val) { int ret, flags; - flags = 0; + flags = fcntl(g_fd, F_GETFL); + if (flags == -1) + return -errno; + if (val) - flags = O_NONBLOCK; + flags |= O_NONBLOCK; + else + flags &= ~O_NONBLOCK; + ret = fcntl(g_fd, F_SETFL, flags); if (ret == -1) return -errno; |