Manual Pages for UNIX Darwin command on man DetachPids
MyWebUniversity

Manual Pages for UNIX Darwin command on man DetachPids

TclDetachPids(3) Tcl Library Procedures TclDetachPids(3)

NAME

TclDetachPids, TclReapDetachedProcs, TclWaitPid - manage child pro-

cesses in background

SYNOPSIS

##iinncclluuddee <>

TTccllDDeettaacchhPPiiddss(numPids, pidPtr) TTccllRReeaappDDeettaacchheeddPPrrooccss() TclPid TTccllWWaaiittPPiidd(pid, statPtr, options) AARRGGUUMMEENNTTSS 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. TclPid 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

TTccllDDeettaacchhPPiiddss and TTccllRReeaappDDeettaacchheeddPPrrooccss provide a mechanism for manag-

ing subprocesses that are running in background. These procedures are

needed because the parent of a process must eventually invoke the wwaaiitt-

ppiidd 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 par-

ent continually creates children and doesn't wait on them, the system's process table will eventually overflow, even if all the children have exited. TTccllDDeettaacchhPPiiddss 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. TTccllRReeaappDDeettaacchheeddPPrrooccss invokes the wwaaiittppiidd 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, TTccllRReeaappDDeettaacchheeddPPrrooccss doesn't wait for it to exit; it will check again the next time it is invoked. Tcl automatically calls TTccllRReeaappDDeettaacchheeddPPrrooccss each time the eexxeecc command is executed, so in most cases it isn't necessary for any code outside of Tcl to invoke TTccllRReeaappDDeettaacchheeddPPrrooccss. However, if you call TTccllDDeettaacchhPPiiddss in situations where the eexxeecc command may never get executed, you may wish to call TTccllRReeaappDDeettaacchheeddPPrrooccss from time to time so that background processes can be cleaned up. TTccllWWaaiittPPiidd 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 TTccllRReeaappDDee-

ttaacchheeddPPrrooccss and the channel system to portably access the operating system. KKEEYYWWOORRDDSS background, child, detach, process, wait

Tcl TclDetachPids(3)




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™