For Programmers: Free Programming Magazines  


Home > Archive > Tcl > November 2007 > how to exit a script without causing defunct in system









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author how to exit a script without causing defunct in system
a10.part@gmail.com

2007-11-04, 10:15 pm


Hi, Gurus:

I am using a parent process to execute some sub process by using "exec
xxx.tcl &", but even xxx.tcl exit normally, I always found a xxx
defunct in linux system, how to avoid this? thanks.

/zhenwu

Darren New

2007-11-05, 4:29 am

a10.part@gmail.com wrote:
> I am using a parent process to execute some sub process by using "exec
> xxx.tcl &", but even xxx.tcl exit normally, I always found a xxx
> defunct in linux system, how to avoid this? thanks.


I think the next time you use [exec], it will clean up the defunct child
process. There are also tools in TclX to let you take actions when a
child exits.

--
Darren New / San Diego, CA, USA (PST)
Remember the good old days, when we
used to complain about cryptography
being export-restricted?
a10.part@gmail.com

2007-11-05, 4:29 am


Yes, you are right, and also I searched this group and found lots of
posts regarding this issue. One solution is that issuing "exec true"
to remove this defunct and it seems working. thank you anyway.

/zhenwu

On Nov 4, 9:36 pm, Darren New <d...@san.rr.com> wrote:
> a10.p...@gmail.com wrote:
>
> I think the next time you use [exec], it will clean up the defunct child
> process. There are also tools in TclX to let you take actions when a
> child exits.
>
> --
> Darren New / San Diego, CA, USA (PST)
> Remember the good old days, when we
> used to complain about cryptography
> being export-restricted?



Robert Heller

2007-11-05, 7:24 pm

At Sun, 04 Nov 2007 19:47:17 -0800 a10.part@gmail.com wrote:

>
>
> Hi, Gurus:
>
> I am using a parent process to execute some sub process by using "exec
> xxx.tcl &", but even xxx.tcl exit normally, I always found a xxx
> defunct in linux system, how to avoid this? thanks.


The parent process needs to 'wait' (see 'man 2 wait').

>
> /zhenwu
>
>


--
Robert Heller -- Get the Deepwoods Software FireFox Toolbar!
Deepwoods Software -- Linux Installation and Administration
http://www.deepsoft.com/ -- Web Hosting, with CGI and Database
heller@deepsoft.com -- Contract Programming: C/C++, Tcl/Tk

Alexandre Ferrieux

2007-11-05, 7:24 pm

On Nov 5, 4:27 pm, Robert Heller <hel...@deepsoft.com> wrote:
> At Sun, 04 Nov 2007 19:47:17 -0800 a10.p...@gmail.com wrote:
>
>
>
>
>
> The parent process needs to 'wait' (see 'man 2 wait').


Yes, but it's not that easy to call a syscall directly from Tcl ;-)
Fortunately,

Tcl automatically calls Tcl_ReapDetachedProcs each time the
exec command is executed, so in most cases it isn't necessary
for any code outside of Tcl to invoke Tcl_ReapDetachedProcs.

(this is from the DetachPids manpage in the Tcl documentation).
Now it could be argued that exposing Tcl_ReapDetachedProcs to script
level would be more elegant than [exec true]...

-Alex



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com