Justin Pryzby <[EMAIL PROTECTED]> writes:
> It notices that there's an rc file:
> |open("/home/pryzbyj/.fetchmailrc", O_RDONLY) = 4
>
> WTF?
> |ioctl(4, SNDCTL_TMR_TIMEBASE or TCGETS, 0xafa04e58) = -1 ENOTTY
> (Inappropriate ioctl for device)
glibc at work, probably isatty() or equivalent to find out the default
buffer size (line vs. fully buffered).
> Huh? Yes, we are a process..
> |kill(0, SIG_0) = 0
> |close(4) = 0
That's indeed a bug, and it's easy to fix (patch attached, description
below). The fscanf() in fm_lock_state() returns EOF; which isn't handled
in <= 6.3.4.
Nico, I suggest to demote the severity to "normal" or "minor" (your
decision), tag fixed-upstream,confirmed,patch and add the attached
patch since it'll take some time until 6.3.5, there are some nontrivial
fixes in the pipeline.
I find the PID of 0 astonishing however. Is Debian's GCC different than
SUSE's? The PID passed to kill is an uninitialized auto variable, and
that it's 0 on your AND Nico's computer leaves me at a loss (and this is
what causes the "lockfile exists" issue), it should contain garbage
(which would cause fetchmail to erase the lockfile in most of the
cases).
> It *tries* to tell me something:
Please report logging issues separately. Merging two issues into one bug
report isn't particularly helpful. I'm cloning the bug.
Patch description (doesn't address logging): (1) fix lockfile bug, by
treating short lockfiles as stale. (2) close the lockfile stream before
attempting to delete the file, and report "removing stale lockfile"
before trying so. (Note that the fclose() before exit() is just
cosmetics and not fixing a leak, exit() is supposed to close all open
files anyways.)
--
Matthias Andree
Index: lock.c
===================================================================
--- lock.c (revision 4826)
+++ lock.c (working copy)
@@ -85,20 +85,21 @@
if (ferror(lockfp)) {
fprintf(stderr, GT_("fetchmail: error reading lockfile \"%s\": %s\n"),
lockfile, strerror(errno));
+ fclose(lockfp); /* not checking should be safe, file mode was "r" */
exit(PS_EXCLUDE);
}
+ fclose(lockfp); /* not checking should be safe, file mode was "r" */
- if (args == 0 || kill(pid, 0) == -1) {
+ if (args == EOF || args == 0 || kill(pid, 0) == -1) {
pid = 0;
+
+ fprintf(stderr,GT_("fetchmail: removing stale lockfile\n"));
if (unlink(lockfile)) {
if (errno != ENOENT) {
perror(lockfile);
}
- } else {
- fprintf(stderr,GT_("fetchmail: removing stale lockfile\n"));
}
}
- fclose(lockfp); /* not checking should be safe, file mode was "r" */
} else {
pid = 0;
if (errno != ENOENT) {