linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* g_serial hangs on write when the cable is disconnected
@ 2015-08-05 10:05 Laszlo Papp
       [not found] ` <CAOMwXhNwVKCK1+-q+fAgMc0ebpremXd+S1kUvZ9Ank-5BTMLCA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 15+ messages in thread
From: Laszlo Papp @ 2015-08-05 10:05 UTC (permalink / raw)
  To: linux-serial-u79uwXL29TY76Z2rM5mHXA,
	linux-usb-u79uwXL29TY76Z2rM5mHXA

Hi,

The code below reproduces the issue. The code is intentionally kept
small, so it deliberately does not have error checking, et al.

Now, my concern is that it blocks for the write operation if the cable
is disconnected. This is not inline with the /dev/ttyS* operation, for
instance. They would not block if I disconnected the serial cable.

Is this a bug or feature? :-) If it turns out to be a feature, is it
better to use O_NONBLOCK if one does not want to use pthreads, etc?

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

int main()
{
    const char buf[] = "Hello World!\n";
    int fd = open("/dev/ttyGS0", O_RDWR | O_NONBLOCK);
    int sent = write(fd, buf, sizeof(buf)-1);
    close(fd);
    return 0;
}

Cheers, L.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2015-08-06 16:16 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-05 10:05 g_serial hangs on write when the cable is disconnected Laszlo Papp
     [not found] ` <CAOMwXhNwVKCK1+-q+fAgMc0ebpremXd+S1kUvZ9Ank-5BTMLCA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-08-05 14:56   ` Greg KH
     [not found]     ` <20150805145627.GA610-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
2015-08-05 15:40       ` Laszlo Papp
     [not found]         ` <CAOMwXhM7TNZAGOUAC=gcwjqTz8y7FGs0FRbJb4SQO+VfbzYJJA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-08-05 16:29           ` Greg KH
     [not found]             ` <20150805162923.GC21870-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
2015-08-05 17:09               ` Peter Stuge
     [not found]                 ` <20150805170927.20219.qmail-Y+HMSxxDrH8@public.gmane.org>
2015-08-05 17:26                   ` Greg KH
     [not found]                     ` <20150805172640.GB25008-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
2015-08-05 18:15                       ` Alan Stern
     [not found]                         ` <Pine.LNX.4.44L0.1508051411090.1713-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2015-08-06  6:05                           ` Laszlo Papp
     [not found]                             ` <CAOMwXhNPi-5iF7BDnb0FTCA885yYJd_UdZyU2RtUL13gw08Z4g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-08-06 13:52                               ` Alan Stern
     [not found]                                 ` <Pine.LNX.4.44L0.1508060951250.1844-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2015-08-06 14:03                                   ` Laszlo Papp
     [not found]                                     ` <CAOMwXhPpqEPV+PqM6BgJNByGCKVT4-a3s49iGdrk37VCcX+jQg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-08-06 14:15                                       ` Alan Stern
2015-08-06 15:16                                       ` Peter Hurley
     [not found]                                         ` <55C37A49.3020503-WaGBZJeGNqdsbIuE7sb01tBPR1lH4CV8@public.gmane.org>
2015-08-06 16:16                                           ` Laszlo Papp
2015-08-06  6:01                   ` Laszlo Papp
2015-08-06  5:59               ` Laszlo Papp

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).