Hi, Please apply attached patch for correcting the documentation issue.
People have been writing code not checking sem_wait() for far too long and this is really a important issue! For instance, the following program would be intended to hang forever: #include <semaphore.h> #include <stdio.h> #include <signal.h> #include <errno.h> void sig(int sig) { } sem_t sem; int err; int main(void) { signal(SIGWINCH, sig); sem_init(&sem, 0, 0); printf("%d\n",sem_wait(&sem)); err = errno; perror("sem_wait"); printf("%d\n",err); return 0; } But if one just resizes the terminal in which it is running, hence a SIGWINCH is sent, sem_wait returns -1/EINTR (normal posix behavior) and the program terminates... Regards, Samuel
--- sem_wait_orig.3 2005-10-08 15:49:42.000000000 +0200 +++ sem_wait.3 2005-10-08 15:50:35.000000000 +0200 @@ -83,7 +83,7 @@ .SH "RETURN VALUE" -The !sem_wait! and !sem_getvalue! functions always return 0. +The !sem_getvalue! function always returns 0. All other semaphore functions return 0 on success and -1 on error, in addition to writing an error code in !errno!. @@ -99,6 +99,18 @@ |pshared| is not zero .RE +The !sem_wait! function sets !errno! to the following code on error: +.RS +.TP +!EINTR! +A signal interrupted this function. Hence the operation was +.B +not +completed and the caller needs to try again. +.RE + + + The !sem_trywait! function sets !errno! to the following error code on error: .RS .TP