From 7d6db66be21f22ad45c2ed961adb8eb10a7ea35e Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Tue, 4 Dec 2012 10:36:54 -0500 Subject: Fix amazingly long-standing thinko in writing the pid file to the lock. --- src/rename_device.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/rename_device.c') diff --git a/src/rename_device.c b/src/rename_device.c index f96291b0..c6a99152 100644 --- a/src/rename_device.c +++ b/src/rename_device.c @@ -241,7 +241,10 @@ void take_lock() { while (1) { lockfd = open(LOCKFILE, O_RDWR|O_CREAT|O_EXCL, 0644); if (lockfd != -1) { - write(lockfd,"%d\n",getpid()); + char buf[32]; + + snprintf(buf,32,"%d\n",getpid()); + write(lockfd,buf,strlen(buf)); close(lockfd); break; } -- cgit v1.2.1 From cd46bb84ea77fbd4c9a97f782efad3af9c3bda08 Mon Sep 17 00:00:00 2001 From: Lukas Nykryn Date: Thu, 11 Jul 2013 10:05:07 +0200 Subject: rename_device: don't wait for lock with lower permissions When running udevadm test as a normal user, rename_device hang for 20 seconds. --- src/rename_device.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/rename_device.c') diff --git a/src/rename_device.c b/src/rename_device.c index c6a99152..8e28154d 100644 --- a/src/rename_device.c +++ b/src/rename_device.c @@ -247,7 +247,9 @@ void take_lock() { write(lockfd,buf,strlen(buf)); close(lockfd); break; - } + } else if (errno == EACCES) + break; + count++; /* If we've slept for 20 seconds, break the lock. */ if (count >= 200) { -- cgit v1.2.1