For Programmers: Free Programming Magazines  


Home > Archive > Unix Programming > July 2005 > Re: Serial port: open vs fcntl









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Serial port: open vs fcntl
Pascal Bourguignon

2005-07-30, 9:01 am

"Simon Elliott" <Simon at ctsn.co.uk> writes:

> In a lot of serial port code examples, there are calls to both open and
> fcntl to set/clear flags, for example:
>
> fd = open(devicename, O_RDWR | O_NOCTTY | O_NDELAY);
> fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NDELAY));
>
> If you want nonblocking I/O with the O_NDELAY option, is it necessary
> to specify it twice, once in the open() call and once in the fcntl()
> call?


I'd guess not, but I suspect it's done for portability reasons.
Perhaps there are some OS where O_NDELAY is not taken into account
when passed to open(2).

--
"Specifications are for the weak and timid!"
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com