Re: Threads

Richard B. Johnson (root@chaos.analogic.com)
Mon, 4 Oct 1999 16:28:30 -0400 (EDT)


On Mon, 4 Oct 1999 sergey@memco.com wrote:

>
> "Richard B. Johnson" <root@chaos.analogic.com> on 10/04/99 12:58:03 PM
> Richard B Johnson worte:
> >On Mon, 4 Oct 1999, Stanislav Krasilovskiy wrote:
>
> >> Hi,
> >>
> >> I have a short question, but I lack the expertise to answer it.
> >>
> >> I am creating a thread in a custom system call, through a call to
> >> kernel_thread(). When this thread finishes, it becomes a zombie and
> >> persists until the user program which called the system call exits. Is
> >> there any way to all to make the kernel thread die cleanly when it
> >> finishes? (Without doing something like waitpid()).
> >>
> >> Thank you very much.
>
> >Make a signal handler for the children (a generic one for all of them).
> >
> >#include<signal.h>
> >#include<sys/wait.h>
> >
> >void reaper(int unused)
> >{
> > while(wait3(&unused, WNOHANG, NULL) > 0)
> > ;
> >}
> > *** SKIPPED ***
>
> Where is a better idea. Just change a parent to INIT process.
> First detach process from old parent ( look at sys_wait() for help ) and
> attach it to process #1 ( sys_fork() ). Don't forget lock kernel before.
> Unfortunatly multiprocessor LINUX still has uniprocessor kernel.
>
> Sergey Tsybanov

I sure don't understand how passing the problem along to init is a better
idea. Generally, we try to fix our own screw-ups, rather than getting
other tasks involved.

Cheers,
Dick Johnson
**** FILE SYSTEM WAS MODIFIED ****
Penguin : Linux version 2.3.13 on an i686 machine (400.59 BogoMips).
Warning : It's hard to remain at the trailing edge of technology.

-
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/