Package: fusesmb Version: 0.8.7-1 Severity: normal Tags: patch Right now, fusesmb just checks if the pidfile is greater than half an hour old before deciding that the old cache process is not running. Since it doesn't check that the process is actually running before giving up, this produces wrong results. Additionally, it also assumes that a cache process running for half an hour is always dead, which seems wrong to me.
This still doesn't catch the case of a running process without a pidfile, but it's better than it was. It also doesn't inspect errno in any of the failure cases, but I don't actually think the reason for failure is that important - feel free to make it more informative. Cheers, Patch below: --- fusesmb-0.8.7/cache.c +++ fusesmb-0.8.7/cache.c @@ -30,6 +30,7 @@ #include <stdlib.h> #include <errno.h> #include <sys/types.h> +#include <signal.h> #include <unistd.h> #include "stringlist.h" @@ -513,12 +514,34 @@ if (-1 != stat(pidfile, &st)) { - if (time(NULL) - st.st_mtime > 30*60) - unlink(pidfile); + + FILE *f; + pid_t pid_from_file; + int n; + if ((f=fopen(pidfile, "r"))) + { + n = fscanf(f, "%d", &pid_from_file); + fclose(f); + if (n != 1) + { + fprintf(stderr, "Error: Can't find pid in pid file\n"); + } + else + { + if ((kill (pid_from_file, 0)) == 0) + { + fprintf(stderr, "Error: %s is already running with %d\n", argv[0], pid_from_file); + exit(EXIT_FAILURE); + } + else + { + unlink(pidfile); + } + } + } else { - fprintf(stderr, "Error: %s is already running\n", argv[0]); - exit(EXIT_FAILURE); + fprintf(stderr, "Error: Can't read pid file\n"); } } -- System Information: Debian Release: lenny/sid APT prefers unstable APT policy: (500, 'unstable'), (1, 'experimental') Architecture: i386 (i686) Kernel: Linux 2.6.26-1-686 (SMP w/1 CPU core) Locale: LANG=en_US.utf8, LC_CTYPE=en_US.utf8 (charmap=UTF-8) (ignored: LC_ALL set to en_US.utf8) Shell: /bin/sh linked to /bin/dash -- ----------------------------------------------------------------- | ,''`. Stephen Gran | | : :' : [EMAIL PROTECTED] | | `. `' Debian user, admin, and developer | | `- http://www.debian.org | ----------------------------------------------------------------- -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]