2 * Print flags for specified file-descriptor
10 #include <sys/types.h>
12 int main(int argc
, char *argv
[])
17 fprintf(stderr
, "usage: a.out <descriptor#>\n");
21 if ((val
= fcntl(atoi(argv
[1]), F_GETFL
, 0)) < 0) {
22 fprintf(stderr
, "fcntl error for fd %d: %s\n", atoi(argv
[1]),
27 accmode
= val
& O_ACCMODE
;
28 if (accmode
== O_RDONLY
)
30 else if (accmode
== O_WRONLY
)
32 else if (accmode
== O_RDWR
)
35 printf("unknow access mode");
41 printf(", nonblocking");
44 printf(", synchornous writes");