[LWN Logo]

To:	Linus Torvalds <torvalds@transmeta.com>
Subject: [Patch] interuptible core dumps
From:	Christoph Rohland <hans-christoph.rohland@sap.com>
Date:	26 Apr 2000 19:29:30 +0200

--=-=-=

Hi Linus,

This patch against 2.3.99-pre6-6 makes core dumping interuptible with
SIGKILL. This makes netscape over NFS home directories much easier to
use ;-)

Greetings
		Christoph

-- 

--=-=-=
Content-Disposition: attachment; filename=patch-core_intr

diff -uNr pre6-6patched/fs/binfmt_elf.c c6/fs/binfmt_elf.c
--- pre6-6patched/fs/binfmt_elf.c	Tue Apr 25 13:43:05 2000
+++ c6/fs/binfmt_elf.c	Wed Apr 26 19:21:20 2000
@@ -991,6 +991,7 @@
 	struct elf_prstatus prstatus;	/* NT_PRSTATUS */
 	elf_fpregset_t fpu;		/* NT_PRFPREG */
 	struct elf_prpsinfo psinfo;	/* NT_PRPSINFO */
+	sigset_t save_set;
 
 	segs = current->mm->map_count;
 
@@ -998,6 +999,10 @@
 	printk("elf_core_dump: %d segs %lu limit\n", segs, limit);
 #endif
 
+	spin_lock_irq(&current->sigmask_lock);
+	save_set = current->blocked;	
+	spin_unlock_irq(&current->sigmask_lock);
+
 	/* Set up header */
 	memcpy(elf.e_ident, ELFMAG, SELFMAG);
 	elf.e_ident[EI_CLASS] = ELF_CLASS;
@@ -1181,6 +1186,12 @@
 
 	DUMP_SEEK(dataoff);
 
+	/* Only allow SIGKILL */
+	spin_lock_irq(&current->sigmask_lock);
+	sigfillset(&current->blocked);
+	sigdelsetmask(&current->blocked, sigmask(SIGKILL));
+	spin_unlock_irq(&current->sigmask_lock);
+
 	for(vma = current->mm->mmap; vma != NULL; vma = vma->vm_next) {
 		unsigned long addr;
 
@@ -1208,6 +1219,8 @@
 			    pte_none(*pte)) {
 				DUMP_SEEK (file->f_pos + PAGE_SIZE);
 			} else {
+				if (signal_pending(current)) 
+					goto end_coredump;
 				DUMP_WRITE((void*)addr, PAGE_SIZE);
 			}
 		}
@@ -1220,6 +1233,9 @@
 	}
 
  end_coredump:
+	spin_lock_irq(&current->sigmask_lock);
+	current->blocked = save_set;
+	spin_unlock_irq(&current->sigmask_lock);
 	set_fs(fs);
 	return has_dumped;
 }

--=-=-=--

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/