ADC Home > Reference Library > Reference > Mac OS X > Mac OS X Man Pages

 

This document is a Mac OS X manual page. Manual pages are a command-line technology for providing documentation. You can view these manual pages locally using the man(1) command. These manual pages come from many different sources, and thus, have a variety of writing styles.

This manual page is associated with the Mac OS X developer tools. The software or headers described may not be present on your Mac OS X installation until you install the developer tools package. This package is available on your Mac OS X installation DVD, and the latest versions can be downloaded from developer.apple.com.

For more information about the manual page format, see the manual page for manpages(5).



Tcl_DetachPids(3)                          Tcl Library Procedures                          Tcl_DetachPids(3)



____________________________________________________________________________________________________________

NAME
       Tcl_DetachPids, Tcl_ReapDetachedProcs, Tcl_WaitPid - manage child processes in background

SYNOPSIS
       #include <tcl.h>

       Tcl_DetachPids(numPids, pidPtr)

       Tcl_ReapDetachedProcs()

       Tcl_Pid
       Tcl_WaitPid(pid, statPtr, options)

ARGUMENTS
       int   numPids      (in)      Number of process ids contained in the array pointed to by pidPtr.

       int   *pidPtr      (in)      Address of array containing numPids process ids.

       Tcl_Pid            pid(in)   The id of the process (pipe) to wait for.

       int*  statPtr      (out)     The result of waiting on a process (pipe). Either 0 or ECHILD.

       int   options                The  options  controlling  the  wait. WNOHANG specifies not to wait when
                                    checking the process.
____________________________________________________________________________________________________________

DESCRIPTION
       Tcl_DetachPids and Tcl_ReapDetachedProcs provide a mechanism for managing subprocesses that are  run-ning running
       ning  in  background.   These  procedures  are needed because the parent of a process must eventually
       invoke the waitpid kernel call (or one of a few other similar kernel calls) to wait for the child  to
       exit.   Until the parent waits for the child, the child's state cannot be completely reclaimed by the
       system.  If a parent continually creates children and doesn't wait on them, the system's process  ta-ble table
       ble will eventually overflow, even if all the children have exited.

       Tcl_DetachPids  may  be  called  to  ask  Tcl  to take responsibility for one or more processes whose
       process ids are contained in the pidPtr array passed as argument.  The caller presumably has  started
       these processes running in background and doesn't want to have to deal with them again.

       Tcl_ReapDetachedProcs invokes the waitpid kernel call on each of the background processes so that its
       state can be cleaned up if it has exited.  If the process hasn't  exited  yet,  Tcl_ReapDetachedProcs
       doesn't  wait  for  it  to exit;  it will check again the next time it is invoked.  Tcl automatically
       calls Tcl_ReapDetachedProcs each time the exec command is executed, so in most cases it isn't  neces-sary necessary
       sary  for  any code outside of Tcl to invoke Tcl_ReapDetachedProcs.  However, if you call Tcl_Detach-Pids Tcl_DetachPids
       Pids in situations where the exec command may never get executed, you may wish  to  call  Tcl_ReapDe-tachedProcs Tcl_ReapDetachedProcs
       tachedProcs from time to time so that background processes can be cleaned up.

       Tcl_WaitPid  is  a thin wrapper around the facilities provided by the operating system to wait on the
       end of a spawned process and to check a whether spawned process is  still  running.  It  is  used  by
       Tcl_ReapDetachedProcs and the channel system to portably access the operating system.


KEYWORDS
       background, child, detach, process, wait



Tcl                                                                                        Tcl_DetachPids(3)

Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.