Bugzilla – Bug 127547
Blocking file lock functions (lockf,flock,fcntl) do not return after timer signal SIGALRM
Last modified: 2005-10-12 15:15:43 UTC
The file lock functions flock, lockf, fcntl do not return even after the signal SIGALRM has been raised and the handler function has been executed. The functions should return with return value EWOULDBLOCK. This can easily be tested with the listed function sequence and calling the test program in 2 separate terminal sessions: 1. signal 2. setitimer 3. fopen 4. fileno 5. fcntl with F_WRLCK and F_SETLKW (or flock or lockf) 6. getchar (to keep the lock in the 1st session; now start the 2nd test).
Created attachment 53626 [details] test program to produce the file lock error (German messages are printed
Jens, I'm not sure if you are the right victim for this one ;) Anyway, I would expect that this bug is also in the official kernel. If it is a bug.
Andreas, please take a look at this one.
I can reproduce this on 10.0, but not with one of our 2.6.5 kernels. fcntl should return -1 and set errno to EINTR (and not EWOULDBLOCK as written in comment 1) when SIGALRM happens, but the signal is not delivered. Explicitly sending a SIGALRM signal has no effect, either. Looking...
solved: different behaviour of the system call 'signal' in linux and various unix platforms - some use BSD semantics, some others POSIX semantics. use of 'sigaction' instead of 'signal' allows explicit specification.
Could you please be more specific and explain how the issue appears to be fixed from your point of view? Thanks.
I replaced the call 'signal' by 'sigaction' and did NOT specify the flag SA_RESTART, then it works as I expected. I assume that the 'signal' call internally sets the SA_RESTART under Linux.