{"id":7024,"date":"2022-12-20T19:34:40","date_gmt":"2022-12-20T22:34:40","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/tcl_detachpids-man3\/"},"modified":"2022-12-20T19:34:40","modified_gmt":"2022-12-20T22:34:40","slug":"tcl_detachpids-man3","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/tcl_detachpids-man3\/","title":{"rendered":"Tcl_DetachPids (man3)"},"content":{"rendered":"<h1 align=\"center\">Tcl_DetachPids<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#ARGUMENTS\">ARGUMENTS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#KEYWORDS\">KEYWORDS<\/a> <\/p>\n<hr>\n<p>______________________________________________________________________________<\/p>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Tcl_DetachPids, Tcl_ReapDetachedProcs, Tcl_WaitPid \u2212 manage child processes in background<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>#include <tcl.h><\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Tcl_DetachPids<\/b>(<i>numPids, pidPtr<\/i>)<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Tcl_ReapDetachedProcs<\/b>()<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Tcl_Pid <b><br \/> Tcl_WaitPid<\/b>(<i>pid, statusPtr, options<\/i>)<\/p>\n<h2>ARGUMENTS <a name=\"ARGUMENTS\"><\/a> <\/h2>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"31%\">\n<p style=\"margin-top: 1em\">int <i>numPids<\/i> (in)<\/p>\n<\/td>\n<td width=\"20%\"><\/td>\n<td width=\"38%\">\n<p style=\"margin-top: 1em\">Number of process ids contained in the array pointed to by <i>pidPtr<\/i>.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"31%\">\n<p>int <i>*pidPtr<\/i> (in)<\/p>\n<\/td>\n<td width=\"20%\"><\/td>\n<td width=\"38%\">\n<p>Address of array containing <i>numPids<\/i> process ids.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"31%\">\n<p>Tcl_Pid <i>pid<\/i> (in)<\/p>\n<\/td>\n<td width=\"20%\"><\/td>\n<td width=\"38%\">\n<p>The id of the process (pipe) to wait for.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"31%\">\n<p>int <i>*statusPtr<\/i> (out)<\/p>\n<\/td>\n<td width=\"20%\"><\/td>\n<td width=\"38%\">\n<p>The result of waiting on a process (pipe). Either 0 or ECHILD.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"31%\">\n<p>int <i>options<\/i> (in)<\/p>\n<\/td>\n<td width=\"20%\"><\/td>\n<td width=\"38%\">\n<p>The options controlling the wait. WNOHANG specifies not to wait when checking the process.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:62%;\">______________________________________________________________________________<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Tcl_DetachPids<\/b> and <b>Tcl_ReapDetachedProcs<\/b> provide a mechanism for managing subprocesses that are running in background. These procedures are needed because the parent of a process must eventually invoke the <b>waitpid<\/b> 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\u2019s state cannot be completely reclaimed by the system. If a parent continually creates children and doesn\u2019t wait on them, the system\u2019s process table will eventually overflow, even if all the children have exited.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Tcl_DetachPids<\/b> may be called to ask Tcl to take responsibility for one or more processes whose process ids are contained in the <i>pidPtr<\/i> array passed as argument. The caller presumably has started these processes running in background and does not want to have to deal with them again.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Tcl_ReapDetachedProcs<\/b> invokes the <b>waitpid<\/b> kernel call on each of the background processes so that its state can be cleaned up if it has exited. If the process has not exited yet, <b>Tcl_ReapDetachedProcs<\/b> does not wait for it to exit; it will check again the next time it is invoked. Tcl automatically calls <b>Tcl_ReapDetachedProcs<\/b> each time the <b>exec<\/b> command is executed, so in most cases it is not necessary for any code outside of Tcl to invoke <b>Tcl_ReapDetachedProcs<\/b>. However, if you call <b>Tcl_DetachPids<\/b> in situations where the <b>exec<\/b> command may never get executed, you may wish to call <b>Tcl_ReapDetachedProcs<\/b> from time to time so that background processes can be cleaned up.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Tcl_WaitPid<\/b> 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 <b>Tcl_ReapDetachedProcs<\/b> and the channel system to portably access the operating system.<\/p>\n<h2>KEYWORDS <a name=\"KEYWORDS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">background, child, detach, process, wait<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  Tcl_DetachPids, Tcl_ReapDetachedProcs, Tcl_WaitPid \u2212 manage child processes in background <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2536],"tags":[2538,3007,3374],"class_list":["post-7024","post","type-post","status-publish","format-standard","hentry","category-3-llamadas-de-bibliotecas","tag-2538","tag-man3","tag-tcl_reapdetachedprocs"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7024","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=7024"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7024\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=7024"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=7024"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=7024"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}