Skip to contentSkip to conversation

2.5.19 daemonize calls reparent_init for you

PATCH In review Rusty Russell 2 participants 2 messages May 30, 2002

Subsystems (10)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 2.5.19 daemonize calls reparent_init for you

daemonize() should call reparent_to_init: a classic mistake (I made it recently).

Future potential cleanups:

	daemonize() should take mask of signals to allow
	kernel_thread() should take a name to copy into ->comm.

Rusty.

kernel/exit.c +2 -0
diff -urN -I \$.*\$ --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.5.19.11306/kernel/exit.c linux-2.5.19.11306.updated/kernel/exit.c
@@ -227,6 +227,8 @@
  	exit_files(current);
 	current->files = init_task.files;
 	atomic_inc(&current->files->count);
+
+	reparent_to_init();
 }
 
 /*
drivers/hotplug/ibmphp_hpc.c +0 -1
diff -urN -I \$.*\$ --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.5.19.11306/drivers/hotplug/ibmphp_hpc.c linux-2.5.19.11306.updated/drivers/hotplug/ibmphp_hpc.c
@@ -1029,7 +1029,6 @@
 	debug ("%s - Entry\n", __FUNCTION__);
 	lock_kernel ();
 	daemonize ();
-	reparent_to_init ();
 
 	//  New name
 	strcpy (current->comm, "hpc_poll");
drivers/mtd/devices/blkmtd.c +0 -1
diff -urN -I \$.*\$ --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.5.19.11306/drivers/mtd/devices/blkmtd.c linux-2.5.19.11306.updated/drivers/mtd/devices/blkmtd.c
@@ -305,7 +305,6 @@
   DEBUG(1, "blkmtd: writetask: starting (pid = %d)\n", tsk->pid);
   daemonize();
   strcpy(tsk->comm, "blkmtdd");
-  tsk->tty = NULL;
   spin_lock_irq(&tsk->sigmask_lock);
   sigfillset(&tsk->blocked);
   recalc_sigpending();
drivers/net/8139too.c +1 -2
diff -urN -I \$.*\$ --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.5.19.11306/drivers/net/8139too.c linux-2.5.19.11306.updated/drivers/net/8139too.c
@@ -1556,8 +1556,7 @@
 	struct rtl8139_private *tp = dev->priv;
 	unsigned long timeout;
 
-	daemonize ();
-	reparent_to_init();
+	daemonize();
 	spin_lock_irq(&current->sigmask_lock);
 	sigemptyset(&current->blocked);
 	recalc_sigpending();
drivers/pnp/pnpbios_core.c +0 -1
diff -urN -I \$.*\$ --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.5.19.11306/drivers/pnp/pnpbios_core.c linux-2.5.19.11306.updated/drivers/pnp/pnpbios_core.c
@@ -610,7 +610,6 @@
 	static struct pnp_docking_station_info now;
 	int docked = -1, d = 0;
 	daemonize();
-	reparent_to_init();
 	strcpy(current->comm, "kpnpbiosd");
 	while(!unloading && !signal_pending(current))
 	{
drivers/usb/storage/usb.c +0 -1
diff -urN -I \$.*\$ --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.5.19.11306/drivers/usb/storage/usb.c linux-2.5.19.11306.updated/drivers/usb/storage/usb.c
@@ -317,7 +317,6 @@
 	 * so get rid of all our resources..
 	 */
 	daemonize();
-	reparent_to_init();
 
 	/* avoid getting signals */
 	spin_lock_irq(&current->sigmask_lock);
fs/jffs2/background.c +0 -1
diff -urN -I \$.*\$ --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.5.19.11306/fs/jffs2/background.c linux-2.5.19.11306.updated/fs/jffs2/background.c
@@ -100,7 +100,6 @@
 	struct jffs2_sb_info *c = _c;
 
 	daemonize();
-	current->tty = NULL;
 	c->gc_task = current;
 	up(&c->gc_thread_start);
 
fs/jfs/jfs_logmgr.c +0 -1
diff -urN -I \$.*\$ --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.5.19.11306/fs/jfs/jfs_logmgr.c linux-2.5.19.11306.updated/fs/jfs/jfs_logmgr.c
@@ -2148,7 +2148,6 @@
 	lock_kernel();
 
 	daemonize();
-	current->tty = NULL;
 	strcpy(current->comm, "jfsIO");
 
 	unlock_kernel();
fs/jfs/jfs_txnmgr.c +0 -2
diff -urN -I \$.*\$ --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.5.19.11306/fs/jfs/jfs_txnmgr.c linux-2.5.19.11306.updated/fs/jfs/jfs_txnmgr.c
@@ -2771,7 +2771,6 @@
 	lock_kernel();
 
 	daemonize();
-	current->tty = NULL;
 	strcpy(current->comm, "jfsCommit");
 
 	unlock_kernel();
@@ -2895,7 +2894,6 @@
 	lock_kernel();
 
 	daemonize();
-	current->tty = NULL;
 	strcpy(current->comm, "jfsSync");
 
 	unlock_kernel();
fs/lockd/clntlock.c +0 -1
diff -urN -I \$.*\$ --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.5.19.11306/fs/lockd/clntlock.c linux-2.5.19.11306.updated/fs/lockd/clntlock.c
@@ -202,7 +202,6 @@
 	struct inode *inode;
 
 	daemonize();
-	reparent_to_init();
 	snprintf(current->comm, sizeof(current->comm),
 		 "%s-reclaim",
 		 host->h_name);
fs/lockd/svc.c +0 -1
diff -urN -I \$.*\$ --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.5.19.11306/fs/lockd/svc.c linux-2.5.19.11306.updated/fs/lockd/svc.c
@@ -98,7 +98,6 @@
 	up(&lockd_start);
 
 	daemonize();
-	reparent_to_init();
 	sprintf(current->comm, "lockd");
 
 	/* Process request with signals blocked.  */
mm/pdflush.c +0 -1
diff -urN -I \$.*\$ --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.5.19.11306/mm/pdflush.c linux-2.5.19.11306.updated/mm/pdflush.c
@@ -82,7 +82,6 @@
 static int __pdflush(struct pdflush_work *my_work)
 {
 	daemonize();
-	reparent_to_init();
 	strcpy(current->comm, "pdflush");
 
 	/* interruptible sleep, so block all signals */

--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

#1 lore raw
Quoted 6 lines · Rusty Russell

daemonize() should call reparent_to_init: a classic mistake (I made it recently).

Future potential cleanups:

	daemonize() should take mask of signals to allow
	kernel_thread() should take a name to copy into ->comm.

Why no generating kernel threads by basically cloning "init"?

This is what we do anyway (creating a clone of init with special properties) but by cloning the current process and adjusting everything needed later to make it appear of a mixture of init clone and idle process clone.

Comments?

Regards

Ingo Oeser

Signature · 1 line
Science is what we can tell a computer. Art is everything else. --- D.E.Knuth