<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>WiredRevolution.com &#187; ttyname</title>
	<atom:link href="http://www.wiredrevolution.com/tag/ttyname/feed" rel="self" type="application/rss+xml" />
	<link>http://www.wiredrevolution.com</link>
	<description>A Bit of Linux Wisdom</description>
	<lastBuildDate>Wed, 18 Jan 2012 22:45:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Find controlling terminal with ttyname</title>
		<link>http://www.wiredrevolution.com/c/find-controlling-terminal-with-ttyname?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=find-controlling-terminal-with-ttyname</link>
		<comments>http://www.wiredrevolution.com/c/find-controlling-terminal-with-ttyname#comments</comments>
		<pubDate>Thu, 06 Nov 2008 13:08:37 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[C]]></category>
		<category><![CDATA[/dev/pts]]></category>
		<category><![CDATA[/dev/tty]]></category>
		<category><![CDATA[controlling]]></category>
		<category><![CDATA[file descriptors]]></category>
		<category><![CDATA[pseudo-terminal]]></category>
		<category><![CDATA[stderr]]></category>
		<category><![CDATA[stdin]]></category>
		<category><![CDATA[stdout]]></category>
		<category><![CDATA[system call]]></category>
		<category><![CDATA[terminal]]></category>
		<category><![CDATA[ttyname]]></category>
		<category><![CDATA[virtual console]]></category>

		<guid isPermaLink="false">http://www.wiredrevolution.com/?p=615</guid>
		<description><![CDATA[<img src="http://www.wiredrevolution.com/wp-content/uploads/c_icon.png" width="80" height="80" alt="" title="C" /><br/>You can identify the path the the controlling terminal device path for your current process in C with the ttyname() system call. This controlling terminal can be a virtual console (/dev/ttyn) or a pseudo-terminal (/dev/pts/n). The ttyname system call takes the following format. char *ttyname(int fd); The stdin, stdout, stderr file descriptors unless redirected are [...]


Related posts<ol><li><a href='http://www.wiredrevolution.com/bash-programming/io-redirection-in-bash' rel='bookmark' title='Permanent Link: I/O redirection in BASH'>I/O redirection in BASH</a></li>
<li><a href='http://www.wiredrevolution.com/c/format-output-using-printf' rel='bookmark' title='Permanent Link: Format output using printf'>Format output using printf</a></li>
<li><a href='http://www.wiredrevolution.com/c/display-hostname-and-ip-address-in-c' rel='bookmark' title='Permanent Link: Display hostname and IP address in C'>Display hostname and IP address in C</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<img src="http://www.wiredrevolution.com/wp-content/uploads/c_icon.png" width="80" height="80" alt="" title="C" /><br/><p>You can identify the path the the controlling terminal device path for your current process in C with the ttyname() system call.  This controlling terminal can be a <strong>virtual console</strong> (<strong>/dev/tty</strong>n) or a <strong>pseudo-terminal</strong> (<strong>/dev/pts/</strong>n).</p>
<p>The ttyname system call takes the following format.</p>
<p><strong>char *ttyname(int fd);</strong></p>
<p>The <strong>stdin</strong>, <strong>stdout</strong>, <strong>stderr</strong> file descriptors unless redirected are by default mapped to the controlling terminal. So for example you can pass it the stdin file descriptor.</p>
<pre>
char * pathname;
pathname = ttyname(0);

printf("controlling terminal : %s\n", pathname);
</pre>
<pre>
controlling terminal : /dev/pts/0
</pre>


<p>Related posts<ol><li><a href='http://www.wiredrevolution.com/bash-programming/io-redirection-in-bash' rel='bookmark' title='Permanent Link: I/O redirection in BASH'>I/O redirection in BASH</a></li>
<li><a href='http://www.wiredrevolution.com/c/format-output-using-printf' rel='bookmark' title='Permanent Link: Format output using printf'>Format output using printf</a></li>
<li><a href='http://www.wiredrevolution.com/c/display-hostname-and-ip-address-in-c' rel='bookmark' title='Permanent Link: Display hostname and IP address in C'>Display hostname and IP address in C</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.wiredrevolution.com/c/find-controlling-terminal-with-ttyname/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

