Eintr Error
Contents |
If the signal handler returns, the system faces the question: what should happen next? POSIX specifies one approach: make the primitive fail right away. The error code for this kind of eintr errno failure is EINTR. This is flexible, but usually inconvenient. Typically, POSIX applications that use eintr linux signal handlers must check for EINTR after each library function that can return it, in order to try the call again. eintr select Often programmers forget to check, which is a common source of error. The GNU C Library provides a convenient way to retry a call after a temporary failure, with the macro TEMP_FAILURE_RETRY: Macro: TEMP_FAILURE_RETRY
Linux Kernel Error Codes
(expression) This macro evaluates expression once, and examines its value as type long int. If the value equals -1, that indicates a failure and errno should be set to show what kind of failure. If it fails and reports error code EINTR, TEMP_FAILURE_RETRY evaluates it again, and over and over until the result is not a temporary failure. The value returned by TEMP_FAILURE_RETRY is whatever value expression produced. eintr signal BSD avoids EINTR entirely and provides a more convenient approach: to restart the interrupted primitive, instead of making it fail. If you choose this approach, you need not be concerned with EINTR. You can choose either approach with the GNU C Library. If you use sigaction to establish a signal handler, you can specify how that handler should behave. If you specify the SA_RESTART flag, return from that handler will resume a primitive; otherwise, return from that handler will cause EINTR. See Flags for Sigaction. Another way to specify the choice is with the siginterrupt function. See BSD Signal Handling. When you don’t specify with sigaction or siginterrupt what a particular handler should do, it uses a default choice. The default choice in the GNU C Library is to make primitives fail with EINTR. The description of each primitive affected by this issue lists EINTR among the error codes it can return. There is one situation where resumption never happens no matter which choice you make: when a data-transfer function such as read or write is interrupted by a signal after transferring part of the data. In this case, the function returns the number of bytes already transferred, indicating partial success. This might a
Programming Boards C Programming (errno == EINTR) means WHAT? thank u! Getting started with C or C++ | C Tutorial | C++ Tutorial | C and C++ FAQ | Get a compiler | Fixes for common problems Thread: linux errno example (errno == EINTR) means WHAT? thank u! Thread Tools Show Printable Version Email this Page…
Posix Error Codes
Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode 02-22-2010 #1 Rede View Profile View Forum Posts Registered
Eintr Read
User Join Date Feb 2010 Posts 13 (errno == EINTR) means WHAT? thank u! I read a program it has : if (errno == EINTR) in that program , if this is true, it will continue... else will throw https://www.gnu.org/s/libc/manual/html_node/Interrupted-Primitives.html a exception.. I don't understand EINTR means and I also cannot find its definition in my whole program packet. If anybody knew, please tell me. thank u! 02-22-2010 #2 Adak View Profile View Forum Posts Registered User Join Date Sep 2006 Posts 8,868 errno.h has a list of errors with these mnemonics. For instance ENOFILE, means you tried to access a file that doesn't exist, etc. They all start with E and are all caps. My compiler uses about http://cboard.cprogramming.com/c-programming/124120-errno-==-eintr-means-what-thank-u.html 30 of these, but not your particular one. They can be used to index into the sys_errlist array and output with perror. Googling on that error mnemonic should get you the answer, quickly. 02-22-2010 #3 Rede View Profile View Forum Posts Registered User Join Date Feb 2010 Posts 13 thank you Adak, yes I know it. it's fork()'s error. Wish somebody know more detail and tell me. Coz I just find general description about this error, still cannot solve my question about my reading program. 02-22-2010 #4 Adak View Profile View Forum Posts Registered User Join Date Sep 2006 Posts 8,868 If you post up the code, when someone comes along with more savvy on this, they'll be much more helpful, seeing the code. I thought it might be an interrupt error, but that's just my guess at it. Google had nothing, huh? 02-22-2010 #5 brewbuck View Profile View Forum Posts Officially An Architect Join Date Mar 2007 Location Portland, OR Posts 7,396 EINTR means "This call did not succeed because it was interrupted. However, if you try again, it will probably work." In other words, EINTR is not a fatal error -- it just means you should retry whatever you were attempting. (Edit: According to my man-page, fork() never should return EINTR, although it may return EAGAIN under certain cases) Code: //try //{ if (a) do { f( b); } while(1); else d
DESCRIPTION top The
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up EINTR and non-blocking calls up vote 9 down vote favorite 6 As is known, some blocking calls like read and write would return -1 and set errno to EINTR, and we need handle this. My question is: Does this apply for non-blocking calls, e.g, set socket to O_NONBLOCK? Since some articles and sources I have read said non-blocking calls don't need bother with this, but I have found no authoritative reference about it. If so, does it apply cross different implementations? nonblocking eintr share|improve this question edited Jan 3 '13 at 12:55 asked Jan 3 '13 at 7:04 haohaolee 305213 add a comment| 1 Answer 1 active oldest votes up vote 16 down vote accepted I cannot give you a definitive answer to this question, and the answer may further vary from system to system, but I would expect a non-blocking socket to never fail with EINTR. If you take a look at the man pages of various systems for the following socket functions bind(), connect(), send(), and receive(), or look those up in the POSIX standard, you'll notice something interesting: All these functions except one may return -1 and set errno to EINTR. The one function that is not documented to ever fail with EINTR is bind(). And bind() is also the only function of that list that will never block by default. So it seems that only