patch-2.3.22 linux/kernel/sched.c

Next file: linux/mm/mmap.c
Previous file: linux/kernel/ksyms.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.21/linux/kernel/sched.c linux/kernel/sched.c
@@ -510,6 +510,7 @@
 			printk(KERN_ERR "schedule_timeout: wrong timeout "
 			       "value %lx from %p\n", timeout,
 			       __builtin_return_address(0));
+			current->state = TASK_RUNNING;
 			goto out;
 		}
 	}
@@ -1181,7 +1182,7 @@
 static inline void do_process_times(struct task_struct *p,
 	unsigned long user, unsigned long system)
 {
-	long psecs;
+	unsigned long psecs;
 
 	psecs = (p->times.tms_utime += user);
 	psecs += (p->times.tms_stime += system);
@@ -1806,6 +1807,35 @@
 	for_each_task(p)
 		show_task(p);
 	read_unlock(&tasklist_lock);
+}
+
+/*
+ *	Put all the gunge required to become a kernel thread without
+ *	attached user resources in one place where it belongs.
+ */
+
+void daemonize(void)
+{
+	struct fs_struct *fs;
+
+
+	/*
+	 * If we were started as result of loading a module, close all of the
+	 * user space pages.  We don't need them, and if we didn't close them
+	 * they would be locked into memory.
+	 */
+	exit_mm(current);
+
+	current->session = 1;
+	current->pgrp = 1;
+
+	/* Become as one with the init task */
+
+	exit_fs(current);	/* current->fs->count--; */
+	fs = init_task.fs;
+	current->fs = fs;
+	atomic_inc(&fs->count);
+
 }
 
 void __init init_idle(void)

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)