kernel_thread()'s become zombies

kernel_thread()'s become zombies

Post by B. James Phillipp » Sun, 11 Apr 1999 04:00:00



Greetings,

I'm writing a module (for 2.2) which starts a kernel thread at insmod time.
I have run into two problems.  The first is that my thread is a child of
insmod unless I start it from outside process context.  Currently I work
around that by launching it from a kernel timer which expires momentarily
after insmod.  The other problem is that when my thread functions exits, it
becomes a zombie.  Is there a way for me to cleanly remove the thread at
rmmod time when it is finished doing it's work?

thanks,
-bp
--

Software Engineer, WGT Inc.     . http://www.terran.org/~bryan

 
 
 

kernel_thread()'s become zombies

Post by David Groth » Sun, 11 Apr 1999 04:00:00


Early in the routine that constitutes the child, do the following:

exit_files(current) ;               /* close all files */
exit_mm(current) ;                  /* detach user pages */
current->pgrp = 1 ;                 /* detach from parent */
current->session = 1 ;              /* now owned by "init" */
current->uid = 0 ;                  /* become root */
current->euid = 0 ;                 /* become root */
current->tty = NULL ;               /* detach from any tty */
current->mm->arg_start = current->mm->arg_end = 0;
strcpy(current->comm, "MyProc") ;   /* set my display name (short string) */

Make sure the string "MyProc" is fairly short.  This will be the display name
of your process in a ps.  It will be enclosed in ()'s.

Have the parent remember the process id somewhere in your driver.

Then when  you want to kill off your process do this (assume process id is in
"my_pid"):

if (my_pid > 0)            /* Only stop the kernel thread if running */
    kill_proc(my_pid, SIGINT, 1) ;

Make sure that any waits that you do in the process are interruptible.

-- Dave


> Greetings,

> I'm writing a module (for 2.2) which starts a kernel thread at insmod time.
> I have run into two problems.  The first is that my thread is a child of
> insmod unless I start it from outside process context.  Currently I work
> around that by launching it from a kernel timer which expires momentarily
> after insmod.  The other problem is that when my thread functions exits, it
> becomes a zombie.  Is there a way for me to cleanly remove the thread at
> rmmod time when it is finished doing it's work?

> thanks,
> -bp
> --

> Software Engineer, WGT Inc.     . http://www.terran.org/~bryan


 
 
 

kernel_thread()'s become zombies

Post by B. James Phillipp » Sun, 11 Apr 1999 04:00:00



> Early in the routine that constitutes the child, do the following:

Hi Dave,

I did all that you said and it made no difference; after the kill_proc, the
thread wakes from interruptible_sleep_on, then does a MOD_DEC_USE_COUNT,
and return 0.  I still end up with a zombie thread.  I am starting this
thread from a kernel timer; is there any way for this to work?

% ps lw 32694
 FLAGS   UID   PID  PPID PRI  NI   SIZE   RSS WCHAN       STA TTY TIME COMMAND
    44     0 32694     0  20  20      0     0  3277c4     Z N ?   0:00
(thread-test <zombie>)

thanks,
-bp
--

Software Engineer, WGT Inc.     . http://www.terran.org/~bryan

 
 
 

kernel_thread()'s become zombies

Post by B. James Phillipp » Tue, 13 Apr 1999 04:00:00




> > I am starting this
> > thread from a kernel timer; is there any way for this to work?

> No. You cannot start threads from interrupts.

Hi Andi,

Correction, you can start them!  I just can't seem to stop them. :(  I have
a small module which does a kernel_thread from the function of a kernel
timer, and it works no problem.  But when the thread dies/returns, it
becomes a zombie.

Any ideas?

thanks,
-bp
--

Software Engineer, WGT Inc.     . http://www.terran.org/~bryan

 
 
 

1. kernel_thread vs. zombie

Hi !

I'm changing the ADB bus reset & probe code to be in a kernel threads
that is created when a bus reset is triggered and that dies of it's own
death.

Everything is fine when the bus reset is triggered during kernel init as
my thread is a child of init. However, when created as a result of an
ioctl, the thread becomes a zombie as it's a child of the process who
caused the ioctl (typically when entering sleep mode).

How do I force a kernel thread to always be a child of init and never
become a zombie ?

I do call daemonize at the beginning of the thread (as it won't do
anything with files, signals or whatever), but that doesn't seem to be enough.

Reagrds,
Ben.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

2. Kernel build problem

3. init process becomes a zombie???

4. Help Logitech Bus Mouse and X

5. Netscape becomes a zombie

6. My apache server cannot be accessed on the other client machine.

7. How processe becomes zombies???

8. Projet manager software for linux

9. Tweaking Linux / Becoming 'guru'

10. How to become user 'news'

11. Server becomes 'deaf' to IP after time

12. How to become user 'news'

13. dd if= of= proces becomes 'uninteruptible sleep' ????