﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-雨前-随笔分类-Linux</title><link>http://www.cppblog.com/mildforest/category/15817.html</link><description>以后开始搞游戏开发了</description><language>zh-cn</language><lastBuildDate>Tue, 10 May 2011 14:06:11 GMT</lastBuildDate><pubDate>Tue, 10 May 2011 14:06:11 GMT</pubDate><ttl>60</ttl><item><title>muduo学习笔记2</title><link>http://www.cppblog.com/mildforest/archive/2011/05/09/146060.html</link><dc:creator>Jokey Pretty</dc:creator><author>Jokey Pretty</author><pubDate>Mon, 09 May 2011 15:16:00 GMT</pubDate><guid>http://www.cppblog.com/mildforest/archive/2011/05/09/146060.html</guid><wfw:comment>http://www.cppblog.com/mildforest/comments/146060.html</wfw:comment><comments>http://www.cppblog.com/mildforest/archive/2011/05/09/146060.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/mildforest/comments/commentRss/146060.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/mildforest/services/trackbacks/146060.html</trackback:ping><description><![CDATA[在服务器端，既需要维护连接的信息，连接发生变化时，还应能通知上面应用层，因此对于事件驱动的服务器，会有各种回调。<br /><br />muduo中服务器端连接的关闭：<br /><br />连接关闭的事件来源：<br /><br />1、底层网络断开，如客户端断开连接，或线路断开，则会在epoll中检测到POLLHUP，Channel在handle该event时，执行closeCallBack回调，从而调用TcpConnection::handleClose();<br /><pre>  TcpConnection::handleClose()</pre><pre>    <font color="#00cc00">将自身状态设置为kDisconnected;</font></pre><pre><font color="#00cc00">    禁用Channel的读写；</font></pre><pre><font color="#00cc00">    进行connectionCallback_回调：</font></pre><pre>        connectionCallback_由TcpServer指定，而在TcpServer中connectionCallback_又由用户指定，<br />        因此它实际上是用来通知上层应用程序，连接即将关闭，请进行相关处理；</pre><pre>    <font color="#00cc00">进行closeCallback_回调：</font></pre><pre>        closeCallback_实际上绑定的是TcpServer::removeConnection，也就是TcpServer对TcpConnection的管理。</pre><pre>        首先从连接表中删除该连接，然后在通知TcpConnection对象，你已经从TcpServer中移除了，<br />        请自身再做一些处理，即调用TcpConnection::connectDestroyed()（从EventLoop中删除自身所对应的Channel）。</pre><pre>        closeCallback_放在最后一行执行并用shared_ptr保护起来，使得函数调用完毕、TcpServer中移除了对其的引用后，<br />        自身的内存能得到释放（shared_ptr的引用计数为1）。</pre>POLLHUP event retrieved<br />    -&gt; Channel::handleEvent<br />    -&gt; Channel::handleEventWithGuard<br />        -&gt; Channel::closeCallback_()<br />        -&gt; TcpConnection::handleClose()<br />            -&gt; Set State to kDisconnected<br />            -&gt; Disable channel<br />            -&gt; connectionCallback_() (customed by application layer)<br />            -&gt; closeCallback_()<br />                -&gt; erase from ConnectionMap<br />                -&gt; TcpConnection::connectDestroyed<br />                    -&gt; remove channel from eventloop<br /><br /><br />2、服务器自身的关闭：<br />    为了优雅的关闭连接，在TcpServer中的析构函数中，会将连接标中的连接一一关闭。因为不同的TcpConnection可能存在于不同IO线程中，因此需要在对应的线程关闭TcpConnection，关闭方法是直接调用TcpConnection::connectDestroyed方法。因为此时TcpConnection此时可能仍然active，因此需要在TcpConnection::connectDestroyed中判断，如果仍avtive则先设置kDisconnected状态，禁用Channel，然后通知应用层。<img src ="http://www.cppblog.com/mildforest/aggbug/146060.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/mildforest/" target="_blank">Jokey Pretty</a> 2011-05-09 23:16 <a href="http://www.cppblog.com/mildforest/archive/2011/05/09/146060.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Ubuntu10.10中安装Macbuntu后的一些Fix</title><link>http://www.cppblog.com/mildforest/archive/2011/04/03/143340.html</link><dc:creator>Jokey Pretty</dc:creator><author>Jokey Pretty</author><pubDate>Sun, 03 Apr 2011 05:59:00 GMT</pubDate><guid>http://www.cppblog.com/mildforest/archive/2011/04/03/143340.html</guid><wfw:comment>http://www.cppblog.com/mildforest/comments/143340.html</wfw:comment><comments>http://www.cppblog.com/mildforest/archive/2011/04/03/143340.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/mildforest/comments/commentRss/143340.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/mildforest/services/trackbacks/143340.html</trackback:ping><description><![CDATA[主要改善了以下问题：<br /><br />1. Eclipse等gtk2程序中，工具栏图标背景色太深，与周边空白区域的颜色非常不协调。<br />    <br />解决方法（可能会有副作用，对其他程序有影响）：<br />      用gedit打开 ~/.themes/Macbuntu/gtk-2.0/gtkrc，找到如下两行：<br /><div style="background-color: rgb(238, 238, 238); font-size: 13px; border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">class </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">*Toolbar</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">         style </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">toolbar</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"><br />widget_class </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">*Toolbar</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">         style </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">toolbar</span><span style="color: rgb(0, 0, 0);">"</span></div><br />将其注释，如下：<br /><br /><div style="background-color: rgb(238, 238, 238); font-size: 13px; border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(128, 0, 0);"># workrounds for eclipse icon backgroud wrong.<br /># class "*Toolbar"         style "toolbar"<br /># widget_class "*Toolbar"         style "toolbar"</span></div><br />2. Eclipse与Firefox的菜单没有出现在全局菜单中。<br /><br />解决办法：<br />       1、禁用Ubuntu10.10的Indicator Applet Appmenu；<br />       2、安装gnome2-globalmenu<br />在<a href="http://gnome-look.org/content/show.php?content=129021&amp;forumpage=0">http://gnome-look.org/content/show.php?content=129021&amp;forumpage=0</a>中提供了一个安装gnome2-globalmenu的补丁，<a href="http://gnome-look.org/content/download.php?content=129021&amp;id=3&amp;tan=47084992">这是链接</a>。<br />PS，上面图标背景色过深的解决方案也是在这条贴中的评论中找到的，见<a href="http://gnome-look.org/content/show.php?content=129021&amp;forumpage=11&amp;PHPSESSID=98ec9053b2aea614fc54b7bb5ae30867">这里</a> 。<br /><br /><div style="background-color: rgb(238, 238, 238); font-size: 13px; border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">Re: Eclipse IDE tool bar problem  -  by bagley on: Oct 18 2010      <br />    <br />GTK theme is eligible for a full rebuild. Meanwhile, you can hash the following lines in the gtkrc (~/.themes/Macbuntu/gtk-2.0/gtkrc).<br /><br />class "*Toolbar" style "toolbar"<br />widget_class "*Toolbar" style "toolbar"<br /><br />Unfortunately, it affects other applications.<br /></span></div><br /><br />3. openoffice/libreoffice的全局菜单问题 --  未解决。<br /><br />4. openoffice/libreoffice的菜单字体过粗。<br />      安装macbuntu后，系统的application font会更改为lucidaGrande，而这会导致openoffice/libreoppenoffice菜单字体过粗。比较无奈的解决办法是把application font改回原来Sans。<br /><img src ="http://www.cppblog.com/mildforest/aggbug/143340.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/mildforest/" target="_blank">Jokey Pretty</a> 2011-04-03 13:59 <a href="http://www.cppblog.com/mildforest/archive/2011/04/03/143340.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Bash行编辑的快捷键-备忘</title><link>http://www.cppblog.com/mildforest/archive/2011/03/27/142809.html</link><dc:creator>Jokey Pretty</dc:creator><author>Jokey Pretty</author><pubDate>Sun, 27 Mar 2011 13:29:00 GMT</pubDate><guid>http://www.cppblog.com/mildforest/archive/2011/03/27/142809.html</guid><wfw:comment>http://www.cppblog.com/mildforest/comments/142809.html</wfw:comment><comments>http://www.cppblog.com/mildforest/archive/2011/03/27/142809.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/mildforest/comments/commentRss/142809.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/mildforest/services/trackbacks/142809.html</trackback:ping><description><![CDATA[在使用Linux命令行时候，经常会有命令输完后，才发现参数忘记加了，或者忘记sudo了，这时候如果用方向键移动，效率非常低，让人崩溃。<br />Bash等shell环境一般会提供行编辑的快捷键，无奈总是记不全，现在记录下来以备忘。<br /><br /><div style="background-color: rgb(238, 238, 238); font-size: 13px; border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">移动<br />ctrl</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">F    向前移动一个字符<br />ctrl</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">B    向后移动一个字符<br />ctrl</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">E    到行尾<br />ctrl</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">A    到行首<br />ctrl</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">L    清屏<br />alt</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">F     到前一个词首<br />alt</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">B     到后一个词首<br /><br /><br /></span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">编辑<br />ctrl</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">D    删除当前字符<br />ctrl</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">V</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">[特殊字符]    添加特殊字符</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">如ctrl</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">V</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">TAB添加一个TAB字符<br />alt</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">U    将当前单词变为大写<br />alt</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">L    将当前单词变为小写<br /><br /></span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">剪切与粘贴<br />ctrl</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">U       剪切到行首<br />ctrl</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">K       剪切到行尾<br />ctrl</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">W       剪切前一个单词<br />ctrl</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">C       删除当前行</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">终止命令<br />alt</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">D        剪切到下个单词<br />ctl</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">Y        粘贴最近剪切的文本<br /><br /></span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">其他<br />Ctrl </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> r     在历史命令中查找<br />Ctrl </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> c     终止命令<br />Ctrl </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> d     退出shell，logout<br />Ctrl </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> z     转入后台运行</span></div><br /><br />另外，在bash中输入 set  -o vi, 之后按esc，就可以使用vim的常用命令了，如shift＋^回到行首，j，k切换前后命令。<br /><br />实际上 bash默认采用emacs模式，常用的ctrl+a, ctrl+p 等等都是emacs的快捷键。<br /><br />恢复回emacs模式：set  -o emacs<br /><br />注：Bash shell set命令<br /><br />使用set命令可以设置各种shell选项或者列出shell变量.单个选项设置常用的特性.<br /><br />在某些选项之后-o参数将特殊特性打开.在某些选项之后使用+o参数将关闭某些特性,<br /><br />不带任何参数的set命令将显示shell的全部变量.除非遇到非法的选项,否则set总是<br /><br />返回ture.<br /><br />当BASH shell被调用时,可以列出全部的选项.当前的选项集列在$-中.在option参数<br /><br />被处理后,其他的参数被赋值到位置参数中($1,$2,...,$n)<img src ="http://www.cppblog.com/mildforest/aggbug/142809.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/mildforest/" target="_blank">Jokey Pretty</a> 2011-03-27 21:29 <a href="http://www.cppblog.com/mildforest/archive/2011/03/27/142809.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>用autotools为westworld生成makefile - 备忘录</title><link>http://www.cppblog.com/mildforest/archive/2011/03/24/142650.html</link><dc:creator>Jokey Pretty</dc:creator><author>Jokey Pretty</author><pubDate>Thu, 24 Mar 2011 07:19:00 GMT</pubDate><guid>http://www.cppblog.com/mildforest/archive/2011/03/24/142650.html</guid><wfw:comment>http://www.cppblog.com/mildforest/comments/142650.html</wfw:comment><comments>http://www.cppblog.com/mildforest/archive/2011/03/24/142650.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/mildforest/comments/commentRss/142650.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/mildforest/services/trackbacks/142650.html</trackback:ping><description><![CDATA[一、开发环境<br />mild:~/program/finite-state-machine/WestWorldWithWoman2$ <font color="#ff0000">uname -a</font><br />Linux mild-F80L 2.6.35-28-generic #49-Ubuntu SMP Tue Mar 1 14:40:58 UTC 2011 i686 GNU/Linux<br /><br />mild:~/program/finite-state-machine/WestWorldWithWoman2$<font color="#000000"><font color="#ff0000">g++ --version</font></font><br />g++ (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5<br />Copyright (C) 2010 Free Software Foundation, Inc.<br /><br />mild:~/program/finite-state-machine/WestWorldWithWoman2$ <font color="#ff0000">automake --version</font><br />automake (GNU automake) 1.11.1<br />Copyright (C) 2009 Free Software Foundation, Inc.<br /><br />mild:~/program/finite-state-machine/WestWorldWithWoman2$ <font color="#ff0000">autoconf --version</font><br />autoconf (GNU Autoconf) 2.6<br /><br />二、源文件目录结构<br />ProjectName<br />      - src<br />          - *.h, *.cpp<br /><br />三、生成步骤<br />1、mild:~/program/finite-state-machine/WestWorldWithWoman2$ <font color="#ff0000">autoscan</font>    <font color="#0000ff">//生成autoscan.log与configure.scan</font><br />     mild:~/program/finite-state-machine/WestWorldWithWoman2$ cp configure.scan configure.ac <br />     mild:~/program/finite-state-machine/WestWorldWithWoman2$ vim configure.ac <br /><div style="background-color: rgb(238, 238, 238); font-size: 13px; border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">  </span><span style="color: rgb(128, 0, 0); font-weight: bold;">1</span><span style="color: rgb(0, 0, 0);"> #                                               </span><span style="color: rgb(128, 128, 128);">-*-</span><span style="color: rgb(0, 0, 0);"> Autoconf </span><span style="color: rgb(128, 128, 128);">-*-</span><span style="color: rgb(0, 0, 0);"><br />  </span><span style="color: rgb(128, 0, 0); font-weight: bold;">2</span><span style="color: rgb(0, 0, 0);"> # Process this </span><span style="color: rgb(0, 0, 255);">file</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">with</span><span style="color: rgb(0, 0, 0);"> autoconf </span><span style="color: rgb(0, 0, 255);">to</span><span style="color: rgb(0, 0, 0);"> produce a configure script.<br />  </span><span style="color: rgb(128, 0, 0); font-weight: bold;">3</span><span style="color: rgb(0, 0, 0);"> <br />  </span><span style="color: rgb(128, 0, 0); font-weight: bold;">4</span><span style="color: rgb(0, 0, 0);"> AC_PREREQ(</span><span style="color: rgb(255, 0, 0);">[</span><span style="color: rgb(255, 0, 0);">2.67</span><span style="color: rgb(255, 0, 0);">]</span><span style="color: rgb(0, 0, 0);">)<br />  </span><span style="color: rgb(128, 0, 0); font-weight: bold;">5</span><span style="color: rgb(0, 0, 0);"> AC_INIT(westworld, </span><span style="color: rgb(128, 0, 0); font-weight: bold;">1.2</span><span style="color: rgb(0, 0, 0);">, wenhl</span><span style="color: rgb(0, 128, 0);">@gmail</span><span style="color: rgb(0, 0, 0);">.com)  # 修改<br />  </span><span style="color: rgb(128, 0, 0); font-weight: bold;">6</span><span style="color: rgb(0, 0, 0);"> AM_INIT_AUTOMAKE    # 添加<br />  </span><span style="color: rgb(128, 0, 0); font-weight: bold;">7</span><span style="color: rgb(0, 0, 0);"> AC_CONFIG_SRCDIR(</span><span style="color: rgb(255, 0, 0);">[</span><span style="color: rgb(255, 0, 0);">src/main.cpp</span><span style="color: rgb(255, 0, 0);">]</span><span style="color: rgb(0, 0, 0);">) #修改<br />  </span><span style="color: rgb(128, 0, 0); font-weight: bold;">8</span><span style="color: rgb(0, 0, 0);"> AC_CONFIG_HEADERS(</span><span style="color: rgb(255, 0, 0);">[</span><span style="color: rgb(255, 0, 0);">config.h</span><span style="color: rgb(255, 0, 0);">]</span><span style="color: rgb(0, 0, 0);">)<br />  </span><span style="color: rgb(128, 0, 0); font-weight: bold;">9</span><span style="color: rgb(0, 0, 0);"> <br /> </span><span style="color: rgb(128, 0, 0); font-weight: bold;">10</span><span style="color: rgb(0, 0, 0);"> # Checks </span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);"> programs.<br /> </span><span style="color: rgb(128, 0, 0); font-weight: bold;">11</span><span style="color: rgb(0, 0, 0);"> AC_PROG_CXX<br /> </span><span style="color: rgb(128, 0, 0); font-weight: bold;">12</span><span style="color: rgb(0, 0, 0);"> AC_PROG_CC<br /> </span><span style="color: rgb(128, 0, 0); font-weight: bold;">13</span><span style="color: rgb(0, 0, 0);"> <br /> </span><span style="color: rgb(128, 0, 0); font-weight: bold;">14</span><span style="color: rgb(0, 0, 0);"> # Checks </span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);"> libraries.<br /> </span><span style="color: rgb(128, 0, 0); font-weight: bold;">15</span><span style="color: rgb(0, 0, 0);"> <br /> </span><span style="color: rgb(128, 0, 0); font-weight: bold;">16</span><span style="color: rgb(0, 0, 0);"> # Checks </span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);"> header files.<br /> </span><span style="color: rgb(128, 0, 0); font-weight: bold;">17</span><span style="color: rgb(0, 0, 0);"> AC_CHECK_HEADERS(</span><span style="color: rgb(255, 0, 0);">[</span><span style="color: rgb(255, 0, 0);">unistd.h</span><span style="color: rgb(255, 0, 0);">]</span><span style="color: rgb(0, 0, 0);">)<br /> </span><span style="color: rgb(128, 0, 0); font-weight: bold;">18</span><span style="color: rgb(0, 0, 0);"> <br /> </span><span style="color: rgb(128, 0, 0); font-weight: bold;">19</span><span style="color: rgb(0, 0, 0);"> # Checks </span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);"> typedefs, structures, </span><span style="color: rgb(128, 128, 128);">and</span><span style="color: rgb(0, 0, 0);"> compiler characteristics.<br /> </span><span style="color: rgb(128, 0, 0); font-weight: bold;">20</span><span style="color: rgb(0, 0, 0);"> AC_HEADER_STDBOOL<br /> </span><span style="color: rgb(128, 0, 0); font-weight: bold;">21</span><span style="color: rgb(0, 0, 0);"> AC_C_INLINE<br /> </span><span style="color: rgb(128, 0, 0); font-weight: bold;">22</span><span style="color: rgb(0, 0, 0);"> <br /> </span><span style="color: rgb(128, 0, 0); font-weight: bold;">23</span><span style="color: rgb(0, 0, 0);"> # Checks </span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);"> library functions.<br /> </span><span style="color: rgb(128, 0, 0); font-weight: bold;">24</span><span style="color: rgb(0, 0, 0);"> AC_CHECK_FUNCS(</span><span style="color: rgb(255, 0, 0);">[</span><span style="color: rgb(255, 0, 0);">sqrt</span><span style="color: rgb(255, 0, 0);">]</span><span style="color: rgb(0, 0, 0);">)<br /> </span><span style="color: rgb(128, 0, 0); font-weight: bold;">25</span><span style="color: rgb(0, 0, 0);"> <br /> </span><span style="color: rgb(128, 0, 0); font-weight: bold;">26</span><span style="color: rgb(0, 0, 0);"> AC_CONFIG_FILES(</span><span style="color: rgb(255, 0, 0);">[</span><span style="color: rgb(255, 0, 0);">Makefile src/Makefile</span><span style="color: rgb(255, 0, 0);">]</span><span style="color: rgb(0, 0, 0);">)  #修改<br /> </span><span style="color: rgb(128, 0, 0); font-weight: bold;">27</span><span style="color: rgb(0, 0, 0);"> <br /> </span><span style="color: rgb(128, 0, 0); font-weight: bold;">28</span><span style="color: rgb(0, 0, 0);"> AC_OUTPUT <br /></span></div><br /><br />2、mild:~/program/finite-state-machine/WestWorldWithWoman2$ <font color="#ff0000">aclocal</font>     <font color="#0000ff">//生成aclocal.m4与autom4te.cache文件</font><br />     mild:~/program/finite-state-machine/WestWorldWithWoman2$ <font color="#ff0000">autoheader</font>   <font color="#0000ff">//生成config.h.in文件</font><br />3、添加Makefile.am、src/Makefile.am<br /><br />Makefile.am<br /><div style="background-color: rgb(238, 238, 238); font-size: 13px; border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">  </span><span style="color: rgb(128, 0, 0); font-weight: bold;">1</span><span style="color: rgb(0, 0, 0);"> AUTOMAKE_OPTIONS</span><span style="color: rgb(128, 128, 128);">=</span><span style="color: rgb(0, 0, 255);">foreign</span><span style="color: rgb(0, 0, 0);"><br />  </span><span style="color: rgb(128, 0, 0); font-weight: bold;">2</span><span style="color: rgb(0, 0, 0);"> SUBDIRS </span><span style="color: rgb(128, 128, 128);">=</span><span style="color: rgb(0, 0, 0);"> src<br /></span></div><br />src/Makefile.am<br /><div style="background-color: rgb(238, 238, 238); font-size: 13px; border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">  </span><span style="color: rgb(128, 0, 0); font-weight: bold;">1</span><span style="color: rgb(0, 0, 0);"> bin_PROGRAMS</span><span style="color: rgb(128, 128, 128);">=</span><span style="color: rgb(0, 0, 0);">westworld<br />  </span><span style="color: rgb(128, 0, 0); font-weight: bold;">2</span><span style="color: rgb(0, 0, 0);"> westworld_SOURCES</span><span style="color: rgb(128, 128, 128);">=</span><span style="color: rgb(0, 0, 0);">BaseGameEntity.cpp \<br />  </span><span style="color: rgb(128, 0, 0); font-weight: bold;">3</span><span style="color: rgb(0, 0, 0);">     main.cpp                         \<br />  </span><span style="color: rgb(128, 0, 0); font-weight: bold;">4</span><span style="color: rgb(0, 0, 0);">     Miner.cpp                        \<br />  </span><span style="color: rgb(128, 0, 0); font-weight: bold;">5</span><span style="color: rgb(0, 0, 0);">     MinerOwnedStates.cpp             \<br />  </span><span style="color: rgb(128, 0, 0); font-weight: bold;">6</span><span style="color: rgb(0, 0, 0);">     MinersWife.cpp                   \<br />  </span><span style="color: rgb(128, 0, 0); font-weight: bold;">7</span><span style="color: rgb(0, 0, 0);">     MinersWifeOwnedStates.cpp   <br />                                      </span></div><br />4、mild:~/program/finite-state-machine/WestWorldWithWoman2$ <font color="#ff0000">automake --add-missing  </font><font color="#0000ff">//生成install-sh, missing, depcomp文件</font><br />5、mild:~/program/finite-state-machine/WestWorldWithWoman2$ <font color="#ff0000">autoconf</font>   <font color="#0000ff">//生成configure脚本</font><br />6、mild:~/program/finite-state-machine/WestWorldWithWoman2$ <font color="#ff0000">./configure </font><br /><br />四、make、make install...<br /><br />五、深入了解autotools。<br /><br /><a target="_blank" href="/Files/mildforest/westworld.tar.gz">源码工程下载</a><br /><br />六、参考<br /><br />http://hi.baidu.com/yzkuang/blog/item/557e4f24423d8136c9955908.html<br />http://blogold.chinaunix.net/u1/51541/showart_2255373.html<br /><br /><br /><img src ="http://www.cppblog.com/mildforest/aggbug/142650.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/mildforest/" target="_blank">Jokey Pretty</a> 2011-03-24 15:19 <a href="http://www.cppblog.com/mildforest/archive/2011/03/24/142650.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Ubuntu 字体设置 - 终于满意了</title><link>http://www.cppblog.com/mildforest/archive/2011/03/13/141734.html</link><dc:creator>Jokey Pretty</dc:creator><author>Jokey Pretty</author><pubDate>Sun, 13 Mar 2011 12:00:00 GMT</pubDate><guid>http://www.cppblog.com/mildforest/archive/2011/03/13/141734.html</guid><wfw:comment>http://www.cppblog.com/mildforest/comments/141734.html</wfw:comment><comments>http://www.cppblog.com/mildforest/archive/2011/03/13/141734.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/mildforest/comments/commentRss/141734.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/mildforest/services/trackbacks/141734.html</trackback:ping><description><![CDATA[昨天心血来潮，把ubuntu升级到了11.04，发现了一大堆麻烦，于是重新装回了10.10。没想到这么一折腾，之前遇到的字体问题又出现了。<br />今天决定一定要fix它，从网上找了一系列方式，依次试了一下，终于找到了一种最满意的效果。<br /><br />首先从windows中拷贝各种需要的字体过来并安装。<br />然后改/etc/fonts/local.conf。具体内容如下：<br /><div style="background-color: rgb(238, 238, 238); font-size: 13px; border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><font face="Courier New"><span style="color: rgb(0, 0, 255);">&lt;?</span><span style="color: rgb(255, 0, 255);">xml version="1.0"</span><span style="color: rgb(0, 0, 255);">?&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">&lt;!</span><span style="color: rgb(255, 0, 255);">DOCTYPE fontconfig SYSTEM "fonts.dtd"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 0);">&lt;!--</span><span style="color: rgb(0, 128, 0);"> /etc/fonts/local.conf file for local customizations </span><span style="color: rgb(0, 128, 0);">--&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">fontconfig</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />     </span><span style="color: rgb(0, 128, 0);">&lt;!--</span><span style="color: rgb(0, 128, 0);">Hinting for SimSun</span><span style="color: rgb(0, 128, 0);">--&gt;</span><span style="color: rgb(0, 0, 0);"><br />    </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">match </span><span style="color: rgb(255, 0, 0);">target</span><span style="color: rgb(0, 0, 255);">="font"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />        </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">test </span><span style="color: rgb(255, 0, 0);">qual</span><span style="color: rgb(0, 0, 255);">="any"</span><span style="color: rgb(255, 0, 0);"> name</span><span style="color: rgb(0, 0, 255);">="family"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />                </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">SimSun</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />                </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">宋体</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />                </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">NSimSun</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />                </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">新宋体</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />        </span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">test</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />      </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">test </span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="weight"</span><span style="color: rgb(255, 0, 0);"> compare</span><span style="color: rgb(0, 0, 255);">="less_eq"</span><span style="color: rgb(255, 0, 0);"> target</span><span style="color: rgb(0, 0, 255);">="pattern"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />         </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">const</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">medium</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">const</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />      </span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">test</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />        </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">test </span><span style="color: rgb(255, 0, 0);">compare</span><span style="color: rgb(0, 0, 255);">="less_eq"</span><span style="color: rgb(255, 0, 0);"> name</span><span style="color: rgb(0, 0, 255);">="pixelsize"</span><span style="color: rgb(0, 0, 255);">&gt;&lt;</span><span style="color: rgb(128, 0, 0);">double</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">17</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">double</span><span style="color: rgb(0, 0, 255);">&gt;&lt;/</span><span style="color: rgb(128, 0, 0);">test</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />        </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">test </span><span style="color: rgb(255, 0, 0);">compare</span><span style="color: rgb(0, 0, 255);">="more_eq"</span><span style="color: rgb(255, 0, 0);"> name</span><span style="color: rgb(0, 0, 255);">="pixelsize"</span><span style="color: rgb(0, 0, 255);">&gt;&lt;</span><span style="color: rgb(128, 0, 0);">double</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">12</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">double</span><span style="color: rgb(0, 0, 255);">&gt;&lt;/</span><span style="color: rgb(128, 0, 0);">test</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />        </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">edit </span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="antialias"</span><span style="color: rgb(255, 0, 0);"> mode</span><span style="color: rgb(0, 0, 255);">="assign"</span><span style="color: rgb(0, 0, 255);">&gt;&lt;</span><span style="color: rgb(128, 0, 0);">bool</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">false</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">bool</span><span style="color: rgb(0, 0, 255);">&gt;&lt;/</span><span style="color: rgb(128, 0, 0);">edit</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />        </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">edit </span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="embeddedbitmap"</span><span style="color: rgb(255, 0, 0);"> mode</span><span style="color: rgb(0, 0, 255);">="assign"</span><span style="color: rgb(0, 0, 255);">&gt;&lt;</span><span style="color: rgb(128, 0, 0);">bool</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">true</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">bool</span><span style="color: rgb(0, 0, 255);">&gt;&lt;/</span><span style="color: rgb(128, 0, 0);">edit</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />        </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">edit </span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="hinting"</span><span style="color: rgb(255, 0, 0);"> mode</span><span style="color: rgb(0, 0, 255);">="assign"</span><span style="color: rgb(0, 0, 255);">&gt;&lt;</span><span style="color: rgb(128, 0, 0);">bool</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">true</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">bool</span><span style="color: rgb(0, 0, 255);">&gt;&lt;/</span><span style="color: rgb(128, 0, 0);">edit</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />        </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">edit </span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="hintstyle"</span><span style="color: rgb(255, 0, 0);"> mode</span><span style="color: rgb(0, 0, 255);">="assign"</span><span style="color: rgb(0, 0, 255);">&gt;&lt;</span><span style="color: rgb(128, 0, 0);">const</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">hintfull</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">const</span><span style="color: rgb(0, 0, 255);">&gt;&lt;/</span><span style="color: rgb(128, 0, 0);">edit</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />        </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">edit </span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="autohint"</span><span style="color: rgb(255, 0, 0);"> mode</span><span style="color: rgb(0, 0, 255);">="assign"</span><span style="color: rgb(255, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />          </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">bool</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">false</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">bool</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />        </span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">edit</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />    </span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">match</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />    </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">match </span><span style="color: rgb(255, 0, 0);">target</span><span style="color: rgb(0, 0, 255);">="pattern"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />      </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">test </span><span style="color: rgb(255, 0, 0);">qual</span><span style="color: rgb(0, 0, 255);">="any"</span><span style="color: rgb(255, 0, 0);"> name</span><span style="color: rgb(0, 0, 255);">="family"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />         </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">serif</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />      </span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">test</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />      </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">edit </span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="family"</span><span style="color: rgb(255, 0, 0);"> mode</span><span style="color: rgb(0, 0, 255);">="prepend"</span><span style="color: rgb(255, 0, 0);"> binding</span><span style="color: rgb(0, 0, 255);">="strong"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />        </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">SimSun</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />        </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">WenQuanYi Zen Hei Sharp</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />         </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">Ubuntu</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />         </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">WenQuanYi Micro Hei</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />         </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">AR PL UMing CN</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />         </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">AR PL ShanHeiSun Uni</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />         </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">Bitstream Vera Serif</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />         </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">DejaVu Serif</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />         </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">AR PL UKai CN</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />         </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">AR PL ZenKai Uni</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />      </span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">edit</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />   </span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">match</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"> <br />   </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">match </span><span style="color: rgb(255, 0, 0);">target</span><span style="color: rgb(0, 0, 255);">="pattern"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />      </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">test </span><span style="color: rgb(255, 0, 0);">qual</span><span style="color: rgb(0, 0, 255);">="any"</span><span style="color: rgb(255, 0, 0);"> name</span><span style="color: rgb(0, 0, 255);">="family"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />         </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">sans-serif</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />      </span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">test</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />      </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">edit </span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="family"</span><span style="color: rgb(255, 0, 0);"> mode</span><span style="color: rgb(0, 0, 255);">="prepend"</span><span style="color: rgb(255, 0, 0);"> binding</span><span style="color: rgb(0, 0, 255);">="strong"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />         </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">SimSun</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />         </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">WenQuanYi Zen Hei Sharp</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />         </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">Ubuntu</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">         <br />         </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">Bitstream Vera Sans</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />         </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">DejaVu Sans</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />         </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">WenQuanYi Zen Hei</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />         </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">AR PL UMing CN</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />         </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">AR PL ShanHeiSun Uni</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />         </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">AR PL UKai CN</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />         </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">AR PL ZenKai Uni</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />      </span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">edit</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />   </span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">match</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"> <br />   </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">match </span><span style="color: rgb(255, 0, 0);">target</span><span style="color: rgb(0, 0, 255);">="pattern"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />      </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">test </span><span style="color: rgb(255, 0, 0);">qual</span><span style="color: rgb(0, 0, 255);">="any"</span><span style="color: rgb(255, 0, 0);"> name</span><span style="color: rgb(0, 0, 255);">="family"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />         </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">monospace</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />      </span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">test</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />      </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">edit </span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="family"</span><span style="color: rgb(255, 0, 0);"> mode</span><span style="color: rgb(0, 0, 255);">="prepend"</span><span style="color: rgb(255, 0, 0);"> binding</span><span style="color: rgb(0, 0, 255);">="strong"</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">     <br />         </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">SimSun</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />         </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">WenQuanYi Zen Hei Sharp</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />         </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">WenQuanYi Micro Hei Mono</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />         </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">Bitstream Vera Sans Mono</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />         </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">DejaVu Sans Mono</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />         </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">WenQuanYi Zen Hei</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />         </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">AR PL UMing CN</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />         </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">AR PL ShanHeiSun Uni</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />         </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">AR PL UKai CN</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />         </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">AR PL ZenKai Uni</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">string</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />      </span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">edit</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />   </span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">match</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"> <br /></span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">fontconfig</span><span style="color: rgb(0, 0, 255);">&gt;</span></font><span style="color: rgb(0, 0, 0);"><br /></span></div><br />主要解决了几个问题:<br />   1. 有了习惯的宋体，并且设定了锯齿，使字体不会发虚；<br />   2. 英文字体和中文字体混合显示正常；<br />   3. Chrome下字体显示正常，不会出现方块；<br />   4. Firefox 与 Chrome字体都正常。<br />下次重装，应该就不会焦头烂额了。<br /><img src ="http://www.cppblog.com/mildforest/aggbug/141734.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/mildforest/" target="_blank">Jokey Pretty</a> 2011-03-13 20:00 <a href="http://www.cppblog.com/mildforest/archive/2011/03/13/141734.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>用管道(pipe)使消息队列通知(mq_notify)可以在Select和poll中使用</title><link>http://www.cppblog.com/mildforest/archive/2011/02/24/140611.html</link><dc:creator>Jokey Pretty</dc:creator><author>Jokey Pretty</author><pubDate>Thu, 24 Feb 2011 13:54:00 GMT</pubDate><guid>http://www.cppblog.com/mildforest/archive/2011/02/24/140611.html</guid><wfw:comment>http://www.cppblog.com/mildforest/comments/140611.html</wfw:comment><comments>http://www.cppblog.com/mildforest/archive/2011/02/24/140611.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/mildforest/comments/commentRss/140611.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/mildforest/services/trackbacks/140611.html</trackback:ping><description><![CDATA[这是在Unix网络编程第二卷进程间通信中看到的一个技巧。它使得posix消息队列的mq_notify可以在select中使用。具体方法为：<br /><blockquote>1、建立管道；<br />2、在主线程中用select监听管道的读事件；<br />3、在mq_notify的时间处理程序中往管道里写数据，通知主线程<br /></blockquote>只是不知道这样做，效率怎么样。<br /><br />UNP-IPC有一段实例代码，如下：<br /><div style="background-color: rgb(238, 238, 238); font-family: consolas,Courier New; font-size: 13px; border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 128, 128);"> 1</span> <span style="color: rgb(0, 0, 0);">#include    </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">unpipc.h</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 2</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 3</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">        pipefd[</span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);">];<br /></span><span style="color: rgb(0, 128, 128);"> 4</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">    sig_usr1(</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 128, 128);"> 5</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);"> $$.bp$$ </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 6</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 7</span> <span style="color: rgb(0, 0, 0);">main(</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> argc, </span><span style="color: rgb(0, 0, 255);">char</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">**</span><span style="color: rgb(0, 0, 0);">argv)<br /></span><span style="color: rgb(0, 128, 128);"> 8</span> <span style="color: rgb(0, 0, 0);">{<br /></span><span style="color: rgb(0, 128, 128);"> 9</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">        nfds;<br /></span><span style="color: rgb(0, 128, 128);">10</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">char</span><span style="color: rgb(0, 0, 0);">    c;<br /></span><span style="color: rgb(0, 128, 128);">11</span> <span style="color: rgb(0, 0, 0);">    fd_set    rset;<br /></span><span style="color: rgb(0, 128, 128);">12</span> <span style="color: rgb(0, 0, 0);">    mqd_t    mqd;<br /></span><span style="color: rgb(0, 128, 128);">13</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">buff;<br /></span><span style="color: rgb(0, 128, 128);">14</span> <span style="color: rgb(0, 0, 0);">    ssize_t    n;<br /></span><span style="color: rgb(0, 128, 128);">15</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">struct</span><span style="color: rgb(0, 0, 0);"> mq_attr    attr;<br /></span><span style="color: rgb(0, 128, 128);">16</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">struct</span><span style="color: rgb(0, 0, 0);"> sigevent    sigev;<br /></span><span style="color: rgb(0, 128, 128);">17</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">18</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (argc </span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);">)<br /></span><span style="color: rgb(0, 128, 128);">19</span> <span style="color: rgb(0, 0, 0);">        err_quit(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">usage: mqnotifysig5 &lt;name&gt;</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 128, 128);">20</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">21</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);"> 4open queue, get attributes, allocate read buffer </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">22</span> <span style="color: rgb(0, 0, 0);">    mqd </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> Mq_open(argv[</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">], O_RDONLY </span><span style="color: rgb(0, 0, 0);">|</span><span style="color: rgb(0, 0, 0);"> O_NONBLOCK);<br /></span><span style="color: rgb(0, 128, 128);">23</span> <span style="color: rgb(0, 0, 0);">    Mq_getattr(mqd, </span><span style="color: rgb(0, 0, 0);">&amp;</span><span style="color: rgb(0, 0, 0);">attr);<br /></span><span style="color: rgb(0, 128, 128);">24</span> <span style="color: rgb(0, 0, 0);">    buff </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> Malloc(attr.mq_msgsize);<br /></span><span style="color: rgb(0, 128, 128);">25</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">26</span> <span style="color: rgb(0, 0, 0);">    Pipe(pipefd);<br /></span><span style="color: rgb(0, 128, 128);">27</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">28</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);"> 4establish signal handler, enable notification </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">29</span> <span style="color: rgb(0, 0, 0);">    Signal(SIGUSR1, sig_usr1);<br /></span><span style="color: rgb(0, 128, 128);">30</span> <span style="color: rgb(0, 0, 0);">    sigev.sigev_notify </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> SIGEV_SIGNAL;<br /></span><span style="color: rgb(0, 128, 128);">31</span> <span style="color: rgb(0, 0, 0);">    sigev.sigev_signo </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> SIGUSR1;<br /></span><span style="color: rgb(0, 128, 128);">32</span> <span style="color: rgb(0, 0, 0);">    Mq_notify(mqd, </span><span style="color: rgb(0, 0, 0);">&amp;</span><span style="color: rgb(0, 0, 0);">sigev);<br /></span><span style="color: rgb(0, 128, 128);">33</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">34</span> <span style="color: rgb(0, 0, 0);">    FD_ZERO(</span><span style="color: rgb(0, 0, 0);">&amp;</span><span style="color: rgb(0, 0, 0);">rset);<br /></span><span style="color: rgb(0, 128, 128);">35</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);"> ( ; ; ) {<br /></span><span style="color: rgb(0, 128, 128);">36</span> <span style="color: rgb(0, 0, 0);">        FD_SET(pipefd[</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">], </span><span style="color: rgb(0, 0, 0);">&amp;</span><span style="color: rgb(0, 0, 0);">rset);<br /></span><span style="color: rgb(0, 128, 128);">37</span> <span style="color: rgb(0, 0, 0);">        nfds </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> Select(pipefd[</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">] </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">, </span><span style="color: rgb(0, 0, 0);">&amp;</span><span style="color: rgb(0, 0, 0);">rset, NULL, NULL, NULL);<br /></span><span style="color: rgb(0, 128, 128);">38</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">39</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (FD_ISSET(pipefd[</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">], </span><span style="color: rgb(0, 0, 0);">&amp;</span><span style="color: rgb(0, 0, 0);">rset)) {<br /></span><span style="color: rgb(0, 128, 128);">40</span> <span style="color: rgb(0, 0, 0);">            Read(pipefd[</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">], </span><span style="color: rgb(0, 0, 0);">&amp;</span><span style="color: rgb(0, 0, 0);">c, </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 128, 128);">41</span> <span style="color: rgb(0, 0, 0);">            Mq_notify(mqd, </span><span style="color: rgb(0, 0, 0);">&amp;</span><span style="color: rgb(0, 0, 0);">sigev);            </span><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);"> reregister first </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">42</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">while</span><span style="color: rgb(0, 0, 0);"> ( (n </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> mq_receive(mqd, buff, attr.mq_msgsize, NULL)) </span><span style="color: rgb(0, 0, 0);">&gt;=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">) {<br /></span><span style="color: rgb(0, 128, 128);">43</span> <span style="color: rgb(0, 0, 0);">                printf(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">read %ld bytes\n</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">, (</span><span style="color: rgb(0, 0, 255);">long</span><span style="color: rgb(0, 0, 0);">) n);<br /></span><span style="color: rgb(0, 128, 128);">44</span> <span style="color: rgb(0, 0, 0);">            }<br /></span><span style="color: rgb(0, 128, 128);">45</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (errno </span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);"> EAGAIN)<br /></span><span style="color: rgb(0, 128, 128);">46</span> <span style="color: rgb(0, 0, 0);">                err_sys(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">mq_receive error</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 128, 128);">47</span> <span style="color: rgb(0, 0, 0);">        }<br /></span><span style="color: rgb(0, 128, 128);">48</span> <span style="color: rgb(0, 0, 0);">    }<br /></span><span style="color: rgb(0, 128, 128);">49</span> <span style="color: rgb(0, 0, 0);">    exit(</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 128, 128);">50</span> <span style="color: rgb(0, 0, 0);">}<br /></span><span style="color: rgb(0, 128, 128);">51</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">52</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">53</span> <span style="color: rgb(0, 0, 0);">sig_usr1(</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> signo)<br /></span><span style="color: rgb(0, 128, 128);">54</span> <span style="color: rgb(0, 0, 0);">{<br /></span><span style="color: rgb(0, 128, 128);">55</span> <span style="color: rgb(0, 0, 0);">    Write(pipefd[</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">], </span><span style="color: rgb(0, 0, 0);">""</span><span style="color: rgb(0, 0, 0);">, </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">);    </span><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);"> one byte of 0 </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">56</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">57</span> <span style="color: rgb(0, 0, 0);">}<br /></span><span style="color: rgb(0, 128, 128);">58</span> <span style="color: rgb(0, 0, 0);"></span></div><br /><br /><br /><img src ="http://www.cppblog.com/mildforest/aggbug/140611.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/mildforest/" target="_blank">Jokey Pretty</a> 2011-02-24 21:54 <a href="http://www.cppblog.com/mildforest/archive/2011/02/24/140611.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>关于pthread_cond_wait()函数的理解</title><link>http://www.cppblog.com/mildforest/archive/2011/02/24/140610.html</link><dc:creator>Jokey Pretty</dc:creator><author>Jokey Pretty</author><pubDate>Thu, 24 Feb 2011 13:45:00 GMT</pubDate><guid>http://www.cppblog.com/mildforest/archive/2011/02/24/140610.html</guid><wfw:comment>http://www.cppblog.com/mildforest/comments/140610.html</wfw:comment><comments>http://www.cppblog.com/mildforest/archive/2011/02/24/140610.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/mildforest/comments/commentRss/140610.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/mildforest/services/trackbacks/140610.html</trackback:ping><description><![CDATA[1、pthread_cond_wait()在等待条件变量时，会主动释放锁并且挂起当前线程或进程；<br />   这是Linux man-page上原话：<br /><pre>   These functions(pthread_cond_wait, pthread_cond_timedwait) <b><font color="#ff3300">aotomitically </font>release </b>muetex and cause the calling thread <br />   to <b><font color="#ff0000">block </font></b>on the condition variable cond.</pre>2、pthread_cond_wait如果成功返回，将自动获取先前释放的锁<br />    这是Linux man-page上原话：<br /><pre>    Upon succssful return, the mutex shall have been locked and shall be owned by the calling thread.<br /></pre><p>3、pthread_cond_wait总是与一个布尔判断式相联在一起，如果判断式为真，则线程继续执行，然而pthread_cond_wait返回时无法保证判断式是真是假，因此需要重新判断。</p><pre>   When using condition variables there is always a Boolean predicate involving shared variables associated with <br />   each condtion wait that is ture if the thread should proceed...<br />   Since the return does not imply anything about the value of this predicate, the predicate should be re-evaluated upon such return.<br /></pre><p>4、鉴于第三点，强烈建议pthread_cond_wait与while循环结合使用来检查判断式</p><pre>   It is thus recommened that a condition wait be enclosed in the equivalent of a "while loop" that checks the predicate.<br /></pre><img src ="http://www.cppblog.com/mildforest/aggbug/140610.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/mildforest/" target="_blank">Jokey Pretty</a> 2011-02-24 21:45 <a href="http://www.cppblog.com/mildforest/archive/2011/02/24/140610.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>改善Linux桌面系统性能</title><link>http://www.cppblog.com/mildforest/archive/2011/01/08/138167.html</link><dc:creator>Jokey Pretty</dc:creator><author>Jokey Pretty</author><pubDate>Sat, 08 Jan 2011 13:40:00 GMT</pubDate><guid>http://www.cppblog.com/mildforest/archive/2011/01/08/138167.html</guid><wfw:comment>http://www.cppblog.com/mildforest/comments/138167.html</wfw:comment><comments>http://www.cppblog.com/mildforest/archive/2011/01/08/138167.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/mildforest/comments/commentRss/138167.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/mildforest/services/trackbacks/138167.html</trackback:ping><description><![CDATA[为了提高Linux桌面响应速度，前一阵子给正在使用的Ubuntu打上了BFS补丁。BFS补丁是CK补丁集中的一个，据说可以大大提高Linux桌面系统的响应，详细可以参考LinuxToy上的<a target="_blank" title="BFS 简介" href="http://linuxtoy.org/archives/bfs-intro-future-of-linux-desktop-kernel.html"> BFS 简介</a>。我主要用的方法来自于<a title="http://ubuntuforums.org/showthread.php?t=1637004" href="http://ubuntuforums.org/showthread.php?t=1637004">http://ubuntuforums.org/showthread.php?t=1637004</a>。<br><br>后来又在网上看到了<a target="_blank" title="200+行Kernel补丁显著改善桌面性能 " href="http://linux.solidot.org/article.pl?sid=10/11/17/0132254&amp;tid=7">200+行Kernel补丁显著改善桌面性能 </a>的文章，更有意思的是，还有一个不用打补丁编译内核的替代方案：<a target="_blank" title="200+行内核补丁的替代方案 " href="http://linux.solidot.org/article.pl?sid=10/11/19/0131252">200+行内核补丁的替代方案 </a>。于是马上试了一下，但发现在运行<br>
<div style="background-color: #eeeeee; font-size: 13px; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 98%; font-family: Lucida Console;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">sudo&nbsp;</span><span style="color: #000000;">/</span><span style="color: #000000;">etc</span><span style="color: #000000;">/</span><span style="color: #000000;">rc</span><span style="color: #000000;">.</span><span style="color: #000000;">local</span></div>
的时候，提示错误说<br>
<div style="background-color: #eeeeee; font-size: 13px; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 98%; font-family: Lucida Console;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">mount</span><span style="color: #000000;">:</span><span style="color: #000000;">&nbsp;unknown&nbsp;filesystem&nbsp;type&nbsp;</span><span style="color: #000000;">'</span><span style="color: #000000;">cgroup</span><span style="color: #000000;">'</span></div>
于是我就困惑了，是因为之前打BFS补丁编译内核后，就不支持cgroup了呢，还是因为要重启，单纯运行'sudo /etc/rc.local'不能？<br><br>考虑到这200行+补丁这么牛逼，我决定重启一下，看看能不能work。<br>重启以后，打了BFS补丁的内核加上那段脚本还是不能work。<br>把内核换回未打补丁的，重启，那段脚本起作用了，貌似速度是一样快的。。。= =<br><br> <img src ="http://www.cppblog.com/mildforest/aggbug/138167.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/mildforest/" target="_blank">Jokey Pretty</a> 2011-01-08 21:40 <a href="http://www.cppblog.com/mildforest/archive/2011/01/08/138167.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Ubuntu Grub Rescue 修复</title><link>http://www.cppblog.com/mildforest/archive/2011/01/02/137866.html</link><dc:creator>Jokey Pretty</dc:creator><author>Jokey Pretty</author><pubDate>Sat, 01 Jan 2011 17:48:00 GMT</pubDate><guid>http://www.cppblog.com/mildforest/archive/2011/01/02/137866.html</guid><wfw:comment>http://www.cppblog.com/mildforest/comments/137866.html</wfw:comment><comments>http://www.cppblog.com/mildforest/archive/2011/01/02/137866.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/mildforest/comments/commentRss/137866.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/mildforest/services/trackbacks/137866.html</trackback:ping><description><![CDATA[
<div style="color: rgb(0, 0, 0); font-family: Verdana, Simsun, sans-serif; font-size: 10pt; margin-top: 5px; margin-right: 5px; margin-bottom: 5px; margin-left: 5px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 255, 255); line-height: 22px; background-position: initial initial; background-repeat: initial initial; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; ">笔记本上装的系统比较混乱。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; ">刚开始时候是Windows XP，后来装了openSUSE11。Windows 7出来后，利用在MS实习的便利，装上了Win7。后来对Ubuntu开始感兴趣，又装了Ubuntu 10.04，现在升级到了10.10。这几个系统并存的后果是，一不小心，就进不了系统了，经常是因为弄坏了Ubuntu Grub。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; ">先前几次的几次小问题，很容易就修复了。最近用Win7的时候，看到有一个盘符H：，是未格式化的一个分区，每次都不小心点到它，然后半天响应，弹出一个对话框。终于被它惹怒了，用分区软件把盘符隐藏了起来。没想到一隐藏，反而出问题了。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; ">系统重启后，发现进了grub rescue模式，又进不了系统了。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; ">Google了一番后，很快找到了解决方法，只需在grub rescue命令行下，输入下列命令，就顺利的出现了Grub界面：</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; "></p><div style="background-color: rgb(238, 238, 238); font-size: 13px; border-left-color: rgb(204, 204, 204); padding-right: 5px; padding-bottom: 4px; padding-left: 4px; padding-top: 4px; width: 98%; word-break: break-all; "><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000; ">grub&nbsp;rescue</span><span style="color: #000000; ">&gt;</span><span style="color: #000000; ">&nbsp;</span><span style="color: #0000FF; ">set</span><span style="color: #000000; ">&nbsp;root</span><span style="color: #000000; ">=</span><span style="color: #000000; ">(hd0,</span><span style="color: #000000; ">8</span><span style="color: #000000; ">)<br>grub&nbsp;rescue</span><span style="color: #000000; ">&gt;</span><span style="color: #000000; ">&nbsp;</span><span style="color: #0000FF; ">set</span><span style="color: #000000; ">&nbsp;prefix</span><span style="color: #000000; ">=</span><span style="color: #000000; ">(hd0,</span><span style="color: #000000; ">8</span><span style="color: #000000; ">)</span><span style="color: #000000; ">/</span><span style="color: #000000; ">boot</span><span style="color: #000000; ">/</span><span style="color: #000000; ">grub<br>grub&nbsp;rescue</span><span style="color: #000000; ">&gt;</span><span style="color: #000000; ">&nbsp;insmod&nbsp;normal<br>grub&nbsp;rescue</span><span style="color: #000000; ">&gt;</span><span style="color: #000000; ">&nbsp;normal</span></div><br><p>我猜想是，在Windows里把盘符隐藏后，可能影响了分区的的顺序，从而使原来的(hd0,7)变成了（hd0,8)，从而Grub找不到文件了。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; ">抱着这个想法，我试着启动进入openSUSE，内核自举后，发现无法挂载根文件系统，提示unable to mount root file system，直接掉进了修复模式的root shell。什么都不能改，只好Ctrl+Alt+Del重启，进入Ubuntu。启动到一半时候，提示openSUSE所在分区无法挂载，Ctrl+Alt+F1进入tty1后，发现正在挂的是/dev/sda9，而现在的序号都往后推了一位了，也就是说现在/dev/sda9其实是原来swap分区，当然挂不上去了。手动挂/dev/sda10，顺利挂上去了。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; ">改openSUSE自己的Grub，然后运行sudo update-grub2，重启，3个系统都可以顺利进入了。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; ">总结：</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; ">1、遇到问题不能慌，不能总想着重装。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; ">2、Google是个好哥哥，有事没事多问问他。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; ">3、以后没事少瞎折腾。</p></div><img src ="http://www.cppblog.com/mildforest/aggbug/137866.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/mildforest/" target="_blank">Jokey Pretty</a> 2011-01-02 01:48 <a href="http://www.cppblog.com/mildforest/archive/2011/01/02/137866.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[导入]Linux中进程如何成为守护进程</title><link>http://www.cppblog.com/mildforest/archive/2009/12/11/137870.html</link><dc:creator>Jokey Pretty</dc:creator><author>Jokey Pretty</author><pubDate>Fri, 11 Dec 2009 03:33:00 GMT</pubDate><guid>http://www.cppblog.com/mildforest/archive/2009/12/11/137870.html</guid><wfw:comment>http://www.cppblog.com/mildforest/comments/137870.html</wfw:comment><comments>http://www.cppblog.com/mildforest/archive/2009/12/11/137870.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/mildforest/comments/commentRss/137870.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/mildforest/services/trackbacks/137870.html</trackback:ping><description><![CDATA[
<div>&nbsp;&nbsp;&nbsp; 守护进程运行在后台,不与任何控制终端相关联.守护进程以root用户运行或者其他特殊的用户,并处理一些系统级的任务, 习惯上守护进程的名字以d结尾,但不是必须的.</div>
<div>&nbsp;&nbsp;&nbsp; 对守护进程的两个基本要求: 它必须是init进程的子进程; 不与任何控制终端相关联.</div>
<div>&nbsp;&nbsp;&nbsp; 一般来讲, 进程可以通过以下步骤成为守护进程:</div>
<blockquote>
<div>1. 调用fork(), 创建新的进程, 它会是将来的守护进程.</div>
<div>2. 在守护进程的父进程中调用exit(). 这保证祖父进程(守护进程的祖父进程)确认父进程已经结束. 还保证父进程不再继续运行, 守护进程不是组长进程. 最后一点是顺利完成一下步骤的前提.</div>
<div>3. 调用setsid(), 使得守护进程有一个新的进程组和新的会话, 两者都把它作为首进程, 这也保证它不会与控制终端相关联.</div>
<div>4. 用chdir()将当前工作目录改为根目录. 因为前面调用fork()创建了新进程, 它所继承来的当前工作目录可能在文件系统的任何地方. 而守护进程通常在系统启动时运行, 同时不希望一些随机目录保持打开状态, 也就阻止了管理员卸载守护进程工作目录所在的那个文件系统.</div>
<div>5. 关闭所有的文件描述符. 不需要继承任何打开的文件描述符, 对于无法确认的文件描述符, 让它们继续处于打开状态.</div>
<div>6. 打开0, 1和2号文件描述符(标准输入, 标准输出和标准错误), 把它们重定向到/dev/null.</div>
</blockquote>
<div>根据这些规则, 下面程序可以成为守护进程:</div>
<div>
<div style="padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; border-left-color: rgb(204, 204, 204); width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 128, 128);">&nbsp;1</span>&nbsp;<span style="color: rgb(0, 0, 0);">#include</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">sys</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">types.h</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;2</span>&nbsp;<span style="color: rgb(0, 0, 0);">#include</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">sys</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">stat.h</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;3</span>&nbsp;<span style="color: rgb(0, 0, 0);">#include</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">stdlib.h</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;4</span>&nbsp;<span style="color: rgb(0, 0, 0);">#include</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">stdio.h</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;5</span>&nbsp;<span style="color: rgb(0, 0, 0);">#include</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">fcntl.h</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;6</span>&nbsp;<span style="color: rgb(0, 0, 0);">#include</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">unistd.h</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;7</span>&nbsp;<span style="color: rgb(0, 0, 0);">#include</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">linux</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">fs.h</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;8</span>&nbsp;<span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">&nbsp;9</span>&nbsp;<span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">&nbsp;main(</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">)<br>
</span><span style="color: rgb(0, 128, 128);">10</span>&nbsp;<span style="color: rgb(0, 0, 0);">{<br>
</span><span style="color: rgb(0, 128, 128);">11</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;pid_t&nbsp;pid;<br>
</span><span style="color: rgb(0, 128, 128);">12</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">&nbsp;i;<br>
</span><span style="color: rgb(0, 128, 128);">13</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);">&nbsp;create&nbsp;new&nbsp;process&nbsp;</span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">14</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;pid&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;fork();<br>
</span><span style="color: rgb(0, 128, 128);">15</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">(pid&nbsp;</span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">)&nbsp;</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">;<br>
</span><span style="color: rgb(0, 128, 128);">16</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">else</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">(pid&nbsp;</span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">)&nbsp;exit(EXIT_SUCCESS);<br>
</span><span style="color: rgb(0, 128, 128);">17</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);">&nbsp;create&nbsp;new&nbsp;session&nbsp;and&nbsp;process&nbsp;group&nbsp;</span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">18</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">(setsid()&nbsp;</span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">)&nbsp;</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">;<br>
</span><span style="color: rgb(0, 128, 128);">19</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);">&nbsp;set&nbsp;the&nbsp;working&nbsp;directory&nbsp;to&nbsp;the&nbsp;root&nbsp;directory</span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">20</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">(chdir(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">)&nbsp;</span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">)&nbsp;</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">;<br>
</span><span style="color: rgb(0, 128, 128);">21</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);">&nbsp;close&nbsp;all&nbsp;open&nbsp;files&nbsp;--&nbsp;NR_OPEN&nbsp;is&nbsp;overkill,&nbsp;but&nbsp;works&nbsp;</span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">22</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">(i&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;&nbsp;i&nbsp;</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">&nbsp;NR_OPEN;&nbsp;i</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">)&nbsp;close(i);<br>
</span><span style="color: rgb(0, 128, 128);">23</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);">&nbsp;redirect&nbsp;fd's&nbsp;0,&nbsp;1,&nbsp;2&nbsp;to&nbsp;/dev/null&nbsp;</span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">24</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;open(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">/dev/null</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,&nbsp;O_RDWR);&nbsp;</span><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);">&nbsp;stdin&nbsp;</span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">25</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;dup(</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">);&nbsp;</span><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);">&nbsp;stdout&nbsp;</span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">26</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;dup(</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">);&nbsp;</span><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);">&nbsp;stderr&nbsp;</span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">27</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);">&nbsp;do&nbsp;it&nbsp;daemon&nbsp;thing<img src="http://www.blogjava.net/Images/dot.gif" alt="">.</span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 128, 128);">28</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;<br>
</span><span style="color: rgb(0, 128, 128);">29</span>&nbsp;<span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;<br>
</span><span style="color: rgb(0, 128, 128);">30</span>&nbsp;<span style="color: rgb(0, 0, 0);">}</span></div>
</div>
<div><br>
</div>
<div>许多Unix系统在它们的C函数库中提供了daemon()函数来完成这些工作:</div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span>#include &lt;unistd.h&gt;</div>
<div><span class="Apple-tab-span" style="white-space: pre;"> </span>int daemon(int nochdir, int noclose);</div>
<div><br>
</div>
<img src="http://www.blogjava.net/wenhl5656/aggbug/305533.html" width="1" height="1"><br><br><div align="right"><a style="text-decoration:none;" href="http://www.blogjava.net/wenhl5656/" target="_blank">CodeLoser</a> 2009-12-11 11:33 <a href="http://www.blogjava.net/wenhl5656/archive/2009/12/11/305533.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div><br>文章来源:<a href="http://www.blogjava.net/wenhl5656/archive/2009/12/11/305533.html">http://www.blogjava.net/wenhl5656/archive/2009/12/11/305533.html</a><img src ="http://www.cppblog.com/mildforest/aggbug/137870.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/mildforest/" target="_blank">Jokey Pretty</a> 2009-12-11 11:33 <a href="http://www.cppblog.com/mildforest/archive/2009/12/11/137870.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>