<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE TIP SYSTEM "http://tcl.activestate.com/cgi-bin/tct/tip/tipxml.dtd">
<!-- Converted at Wed May 16 19:57:54 GMT 2012 -->
<!-- TIP AutoGenerator - written by Donal K. Fellows -->

<TIP number='178'>
<header><title>[info pid] and [info tid] Subcommands</title><author address="mailto:joe@mistachkin.com">Joe Mistachkin</author><status type='project' state='draft' tclversion="8.7" vote='prior'>$Revision: 1.9 $</status><history></history><created day='21' month='mar' year='2004' /></header>
<abstract>This TIP proposes two new <emph style="bold">info</emph> subcommands which are used to obtain the current process and thread identifiers.</abstract>
<body><section title="Rationale">
<para>In certain types of applications, it is important to know what thread is currently executing. This is especially true for multithreaded applications or for scripts running in a threaded build of Tcl.</para>
<para>While the author realizes that there is already a <emph style="bold">pid</emph> command, the addition of the <emph style="bold">info pid</emph> subcommand still makes sense for the following reasons:</para>
<itemize><item.i><para>The <emph style="bold">pid</emph> command can also provide information totally unrelated to the <emph style="italic">current</emph> process identifier. At one point (<tipref type="text" tip="88"/>) it was even suggested that the <emph style="bold">pid</emph> command be overloaded to provide process control related functionality.</para></item.i><item.i><para>To allow scripts that dynamically build other scripts (potentially for use with safe interpreters) using the <emph style="bold">info</emph> command and caller provided arguments. Using the <emph style="bold">info</emph> command instead of the <emph style="bold">pid</emph> command limits the amount of information that can be obtained by the safe interpreter.</para></item.i><item.i><para>It is the opinion of the author that <emph style="italic">informational</emph> commands, such as <emph style="bold">pid</emph> should really be subcommands of <emph style="bold">info</emph> as we start to move forward with the development of Tcl.</para></item.i></itemize>
</section>
<section title="Justification">
<para>The <emph style="bold">info tid</emph> command should be in the core because the identity of the currently executing thread is just as fundamental on all modern operating systems as the current process identity. Once the thread identity is known, it can be used to communicate with other processes and threads in useful ways that do not require the Thread package. Loading the entire Thread package just to get the identity of the currently executing thread is overkill and may not be a good solution in application embedding scenarios. This is especially true for the browser plugin where loading extra packages is not ideal.</para>
</section>
<section title="Proposed Change">
<para>Two new subcommands, <emph style="bold">info pid</emph> and <emph style="bold">info tid</emph>, would be added to the <emph style="bold">info</emph> command with the following syntax:</para>
<quote><emph style="bold">info pid</emph></quote>
<para>This subcommand would return the process identifier for the current process.</para>
<quote><emph style="bold">info tid</emph></quote>
<para>This subcommand would return the thread identifier for the current thread.</para>
</section>
<section title="Draft Implmentation">
<para>A complete implementation of this TIP is available [<url ref="http://sf.net/tracker/?func=detail&amp;aid=920731&amp;group_id=10894&amp;atid=310894"/>].</para>
</section>
<section title="Copyright">
<para>This document has been placed in the public domain.</para>
</section>
</body></TIP>

