Question

If a IO system call (e.g. read) returns -1 and error is EINTER, how should we...

If a IO system call (e.g. read) returns -1 and error is EINTER, how should we interpret this? And give 1-2 lines of code to show how to handle that error.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Some system calls report EINTR error code if a signal occured while the system call is in progress. Actually there is no error. The issue is
system is not able to resume the system call due to that signal.So it is better that we should stop the system call if such a thing happens. Following is the sample code to take care of that.

int c = write(fd, &buf, sizeof(v));
if (c == -1 && errno != EINTR) {
    perror("Error in writing");
    exit(EXIT_FAILURE);
}

Add a comment
Know the answer?
Add Answer to:
If a IO system call (e.g. read) returns -1 and error is EINTER, how should we...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT