As the title says, can I do this with a POSIX file descriptor? In my case, it’s a serial device where I have one thread reading and another one writing.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, you can do that with a serial port, no problem.
You could do it with a regular file too, though it would probably be confusing since you’d have to carefully manage the contents of the file so that the reader and writer aren’t stepping on each other and especially carefully manage the seek pointer (use
pread()andpwrite()which don’t depend on the seek pointer). Obviously, with a serial port which has separate in & out directions and no concept of a seek pointer, it’s more straightforward.