From ae5767799a5e329278a1bf8503d9aa57f7ebb3f8 Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Tue, 16 Oct 2007 07:09:03 +0000 Subject: [PATCH] Snapshot work in progress: Don't look for any core file, only the one for the correct PID. Close the log directory no matter what. --- debian/patches/find-core-files | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/debian/patches/find-core-files b/debian/patches/find-core-files index 80d412229..650dc3940 100644 --- a/debian/patches/find-core-files +++ b/debian/patches/find-core-files @@ -8,7 +8,7 @@ #ifdef HAVE_STRING_H #include -@@ -105,13 +106,45 @@ +@@ -105,13 +106,44 @@ char tbuffer[256]; struct stat tstat; register afs_int32 code; @@ -27,34 +27,33 @@ + struct dirent *file; + char *p; + size_t length; ++ char pid[256]; + ++ sprintf(pid, "%d", aproc->pid); + logdir = opendir(AFSDIR_LOGS_DIR); + if (logdir == NULL) + return; + while ((file = readdir(logdir)) != NULL) { + if (strncmp(file->d_name, "core.", 5) != 0) + continue; -+ p = file->d_name + 5; -+ do { -+ if (!isdigit((unsigned int) *p)) -+ break; -+ p++; -+ } while (*p != '\0'); -+ if (*p == '\0') { ++ if (strcmp(file->d_name + 5, pid) == 0) { + length = strlen(AFSDIR_LOGS_DIR) + strlen(file->d_name) + 2; + corefile = malloc(length); -+ if (corefile == NULL) ++ if (corefile == NULL) { ++ closedir(logdir); + return; ++ } + sprintf(corefile, "%s/%s", AFSDIR_LOGS_DIR, file->d_name); + code = 0; + break; + } + } ++ closedir(logdir); + } if (code) return; -@@ -124,7 +157,12 @@ +@@ -124,7 +156,12 @@ TimeFields->tm_hour, TimeFields->tm_min, TimeFields->tm_sec); strcpy(tbuffer, FileName); #endif -- 2.39.5