FreeBSD Bugzilla – Attachment 243325 Details for
Bug 265736
F_SETFL will fail yet still set O_NONBLOCK for character devices that don't implement d_ioctl
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Better test case. It tests both setting and clearing flags.
f_setfl_o_nonblock.c (text/plain), 818 bytes, created by
Alan Somers
on 2023-07-09 20:47:30 UTC
(
hide
)
Description:
Better test case. It tests both setting and clearing flags.
Filename:
MIME Type:
Creator:
Alan Somers
Created:
2023-07-09 20:47:30 UTC
Size:
818 bytes
patch
obsolete
>#include <err.h> >#include <fcntl.h> >#include <stdio.h> >#include <unistd.h> > >void doit(char *devname, int open_flags, int set_flags) { > int orig_flags, new_flags, fd, r; > > fd = open(devname, open_flags); > if (fd < 0) > err(1, "open"); > > orig_flags = fcntl(fd, F_GETFL); > > r = fcntl(fd, F_SETFL, set_flags); > > new_flags = fcntl(fd, F_GETFL); > > if (r < 0) { > printf("F_SETFL failed. Flags changed from %#x to %#x.\n", > orig_flags, new_flags); > } else { > printf("F_SETFL succeeded. Flags changed from %#x to %#x.\n", > orig_flags, new_flags); > } > close(fd); >} > >int main(int argc, char **argv) { > char *devname = argv[1]; > > // First, use fcntl to set O_NONBLOCK > doit(devname, O_RDONLY, O_RDONLY | O_NONBLOCK); > doit(devname, O_RDONLY | O_NONBLOCK, O_RDONLY); > // Then use fcntl to clear O_NONBLOCK > return (0); >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 265736
:
235799
|
243323
| 243325