diff options
Diffstat (limited to 'src/rename_device.c')
-rw-r--r-- | src/rename_device.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/rename_device.c b/src/rename_device.c index f96291b0..bb5e6b8f 100644 --- a/src/rename_device.c +++ b/src/rename_device.c @@ -120,6 +120,14 @@ int isCfg(const struct dirent *dent) { } static inline char *dequote(char *start, char *end) { + char *c; + //remove comments and trailing whitespace + c = strchr(start, '#'); + if (c!=NULL) + *c='\0'; + + g_strchomp(start); + if (end==NULL) { end=start; while(*end) end++; @@ -241,10 +249,15 @@ 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; - } + } else if (errno == EACCES) + break; + count++; /* If we've slept for 20 seconds, break the lock. */ if (count >= 200) { |