33 |
|
|
34 |
fd = fopen(lockfile, "w"); |
fd = fopen(lockfile, "w"); |
35 |
if (fd == NULL) |
if (fd == NULL) |
36 |
fatal(ERROR_FILE_OPEN, "opening lockfile; %s\n", |
fatal(ERROR_FILEOPEN, "opening lockfile; %s\n", |
37 |
strerror(errno)); |
strerror(errno)); |
38 |
fprintf(fd, "%s\n", ultostr(getpid(), 10)); |
fprintf(fd, "%s\n", ultostr(getpid(), 10)); |
39 |
fclose(fd); |
fclose(fd); |
78 |
|
|
79 |
n = 0; |
n = 0; |
80 |
|
|
81 |
snprintf(lockf, PATH_MAX, "%s/%s", home, PATHNAME_LOCK_FILE); |
snprintf(lockf, PATH_MAX, "%s/%s", home, PATHNAME_LOCK); |
82 |
lockfile = xstrdup(lockf); |
lockfile = xstrdup(lockf); |
83 |
|
|
84 |
if (exists_file(lockfile)) { |
if (exists_file(lockfile)) { |
85 |
fd = fopen(lockfile, "r"); |
fd = fopen(lockfile, "r"); |
86 |
if (fd == NULL) |
if (fd == NULL) |
87 |
fatal(ERROR_FILE_OPEN, "opening lockfile; %s\n", |
fatal(ERROR_FILEOPEN, "opening lockfile; %s\n", |
88 |
strerror(errno)); |
strerror(errno)); |
89 |
if (fgets(line, LINE_MAX - 1, fd)) { |
if (fgets(line, LINE_MAX - 1, fd)) { |
90 |
errno = 0; |
errno = 0; |
109 |
|
|
110 |
if (unlink(lockfile) && errno != ENOENT) { |
if (unlink(lockfile) && errno != ENOENT) { |
111 |
error("removing lockfile; %s\n", strerror(errno)); |
error("removing lockfile; %s\n", strerror(errno)); |
112 |
return ERROR_FILE_OPEN; |
return ERROR_FILEOPEN; |
113 |
} |
} |
114 |
return 0; |
return 0; |
115 |
} |
} |