Re: gtk and system



Matt,

    Under UNIX, child processes will wait around until notification that the
parent is "aware" of the childs <defunct> status.  In the GTK application,
after you kill the child's PID, execute a waitpid() on the child's process to
allow the system to clean up all the child's resources.  You can choose to
stop execution in the parent and wait for the child to die, or simply get the
status and continue.  Either way, the child process will go away and you
won't be left with a bunch of zombie processes lying around.


Lance

Matt Eisemann wrote:

> > ----------
> > From:         Matt Eisemann[SMTP:MEISEMANN DSRNET COM]
> > Sent:         Tuesday, October 10, 2000 8:59:34 AM
> > To:   gtk-list gnome org
> > Subject:      gtk and system
> > Auto forwarded by a Rule
> >
> This may not be a gtk problem, but let me explain my problem.  I have an
> GTK+ application which starts processes using fork and execle, which works
> great.  I save the process id (pid) of that process .  Later on, a user
> pushes a button called 'stop tasks' and when called it concatenates the
> 'kill' command with the saved pid.  Below is some basic code.
> When I try to kill the processes I started the system command does not
> return an error code but the process consistently goes into a <defunct>
> mode instead of dying.  However, when I leave my GTK+ application, the
> <defunct> process does die.  But why not immediately.  Is this a gtk
> problem, or a UNIX limitation or is the fact that I started the processes
> with the GTK application cause some sort of a parent - child relationship.
>  Thanks ahead of time for your help.
>
> sprintf(process_id,"%d",tasks->task_list[row].process_id);
> strcpy(executable,"kill -9 ");
> strcat(executable,process_id);
>
>   system(process_id);
>
> _______________________________________________
> gtk-list mailing list
> gtk-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-list

  ------------------------------------------------------------------------
  ___                                          Lance Capser
 /\_ \                          Freelance Web Page Designer / Web Master /
 \//\ \     ___ ___     ___          Unix SysAdmin / C,C++ Programmer
   \ \ \  /' __` __`\  /'___\ ----------------------------------------------
    \_\ \_/\ \/\ \/\ \/\ \__/
    /\____\ \_\ \_\ \_\ \____\         E-Mail: lmc cyberhighway net
    \/____/\/_/\/_/\/_/\/____/            Phone: (208) 461-0222
                                           Pager: (208) 391-0448
 "If DOS had been better in the first place, I might not have started this.-
                                Linus Torvalds







[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]