As reported in https://launchpad.net/bugs/544139, ConsoleKit sometimes fails to track the active VT. This particular case was tracked down to a race condition that happens if you try to open /dev/console while the current TTY is currently being closed. This yields an -EIO error, in which case CK should just try again.
For a more detailled summary of the problem from a kernel perspective, please see https://bugs.launchpad.net/ubuntu/+source/linux/+bug/554172/comments/245 .
We have carried this patch for some months now and also backported it to previous stable releases. It was confirmed to fix the problem and we didn't get any negative feedback about it.
Created attachment 40437 [details] [review]
git formatted patch
Patch by Colin Watson.
Grrr, sleep loops are evil. I wonder if we should just ignore this bug until the BKL is gone. Seems the issue is gone on .38 anyway.
Hmm, so I have discussed this with some folks, and it seems we do need something like this as the kernel will not help us here.
However, I don't think the patch is acceptable: there are other reasons why EIO might be returned. Since we cannot distuingish the error causes we need at least a safe way out. My suggestion would be to retry opening 20 times and then give up. In systemd I have settled to use 20 times with 50ms in between, totalling to 1s in total.
Could you please update the patch? I'll then merge it.
OK, I merged the patch now nonetheless. We should get fixed this properly one day (i.e. only retry a max number), so leaving this bug open.