mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-05-14 23:58:08 +02:00
eis: handle a lock file open failure correctly
Assisted-by: Claude:claude-opus-4-6 Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/388>
This commit is contained in:
parent
c352f16b4a
commit
dc5bd1396f
1 changed files with 7 additions and 3 deletions
|
|
@ -147,11 +147,15 @@ eis_setup_backend_socket(struct eis *eis, const char *socketpath)
|
|||
* socket file. */
|
||||
_cleanup_free_ char *lockfile = xaprintf("%s.lock", path);
|
||||
_cleanup_close_ int lockfd =
|
||||
open(lockfile, O_CREAT | O_CLOEXEC | O_RDWR, S_IRUSR | S_IWUSR);
|
||||
int rc = flock(lockfd, LOCK_EX | LOCK_NB);
|
||||
xerrno(open(lockfile, O_CREAT | O_CLOEXEC | O_RDWR, S_IRUSR | S_IWUSR));
|
||||
int rc;
|
||||
if (lockfd >= 0)
|
||||
rc = xerrno(flock(lockfd, LOCK_EX | LOCK_NB));
|
||||
else
|
||||
rc = lockfd;
|
||||
if (rc < 0) {
|
||||
log_error(eis, "Failed to create lockfile %s, is another EIS running?", lockfile);
|
||||
return -errno;
|
||||
return -rc;
|
||||
}
|
||||
|
||||
struct stat st;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue