fcntl(fd, F_GETFL, intp) does not put the return value into *intp. The
flags are in fcntl()'s return value. Same with 2.4.
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h>
int main()
{
int trigger_pipe[2];
int err;
int flags;
int newflags;
pipe(trigger_pipe);
/* Get flags */
flags = fcntl(trigger_pipe[0], F_GETFL, NULL);
fprintf(stderr, "Set flags: 0x%x\n", flags);
/* Set flags */
flags |= O_NONBLOCK;
err = fcntl(trigger_pipe[0], F_SETFL, flags);
fprintf(stderr, "Set flags: %d\n", err);
/* Check flags */
flags = fcntl(trigger_pipe[0], F_GETFL, NULL);
fprintf(stderr, "Get flags: 0x%0x\n", flags);
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/