<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
> <channel><title>HEAVYWORKS</title> <atom:link href="http://www.heavyworks.net/feed" rel="self" type="application/rss+xml" /><link>http://www.heavyworks.net</link> <description>Extreme Software Engineering</description> <lastBuildDate>Fri, 27 Aug 2010 01:55:58 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3</generator> <item><title>Don&#8217;t be ruthless to your processes</title><link>http://www.heavyworks.net/blog/posts/dont-be-ruthless-to-your-processes</link> <comments>http://www.heavyworks.net/blog/posts/dont-be-ruthless-to-your-processes#comments</comments> <pubDate>Wed, 28 Jul 2010 20:38:35 +0000</pubDate> <dc:creator>Jan Seidl</dc:creator> <category><![CDATA[System Administration]]></category> <category><![CDATA[bsd]]></category> <category><![CDATA[kill]]></category> <category><![CDATA[process]]></category> <category><![CDATA[shell]]></category> <category><![CDATA[signal]]></category> <category><![CDATA[terminal]]></category> <category><![CDATA[unix]]></category> <guid
isPermaLink="false">http://www.heavyworks.net/?p=544</guid> <description><![CDATA[It&#8217;s a common (while wrong) practice while administering *NIX/BSD servers (or even stations) to terminate hanged processes with the kill command. Although the name suggests that it will mercilessly murder the process, its more a signal thrower. Signals tell processes to take determinate actions such as pause, continue, terminate, interrupt current work etc. Anatomy of [...]
No related posts.]]></description> <content:encoded><![CDATA[<p>It&#8217;s a common (while wrong) practice while administering *NIX/BSD servers (or even stations) to terminate hanged processes with the <code>kill</code> command.</p><p>Although the name suggests that it will mercilessly murder the process, its more a <em>signal thrower</em>. Signals tell processes to take determinate actions such as pause, continue, terminate, interrupt current work etc.<br
/> <span
id="more-544"></span></p><h2>Anatomy of process&#8217; death process</h2><p>There are basically four forms to terminate a process:</p><div
id="attachment_547" class="wp-caption aligncenter" style="width: 434px"><img
src="http://www.heavyworks.net/wordpress/wp-content/uploads/killComputer.gif" alt="" title="Killing the PC" width="424" height="341" class="size-full wp-image-547" /><p
class="wp-caption-text">Wrong way to terminate a process</p></div><h3>Signal 15, SIGTERM. The Terminate Call</h3><p>Tells your process to end the task cleanly, closing all network connections, file handles, notifying child processes, resetting the terminal and go home in peace. The first thing to do when it becomes unresponsive.</p><h3>Signal 2, SIGINT. The Interrupt &#8211; A slap on the face</h2><p>Tells your process to stop what it is doing right now and leave immediately. The only way when SIGTERM fails to do the job cleanly. <kbd>CTRL+C</kbd> will throw this signal too.</p><h3>Signal 1, SIGHUP. The Hangup &#8211; Kick on the tummy</h3><p>Quite similar to SIGINT, SIGHUP is one step up. The Hangup is equivalent to the physical medium holding the process going down. It was very common on dial-up lines to indicate that the line had hang-up the call thus terminating the connection.</p><h3>Signal 9, SIGKILL. The Kill &#8211; A bullet on process&#8217; head</h3><p>SIGKILL will wipe the process out from your tree leaving all the crap it was using. Its the worst way of terminating a process since it will keep your resources open and can lead to any sort of mayhem.</p><h2>So what to do?</h2><p>As mentioned on <a
href="http://partmaps.org/era/unix/award.html#uuk9letter">UUK9 (Useless use of Kill -9)</a>:</p><blockquote><p>Generally, send 15 <em>(SIGTERM)</em>, and wait a second or two, and if that doesn&#8217;t<br
/> work, send 2 <em>(SIGINT)</em>, and if that doesn&#8217;t work, send 1 <em>(SIGHUP)</em>.  If that doesn&#8217;t,<br
/> REMOVE THE BINARY because the program is badly behaved!</p></blockquote><p>Quite extremist, but totally true!</p><p>Treat your processes with dignity, and they won&#8217;t betray you! HTH!</p><p>No related posts.</p>]]></content:encoded> <wfw:commentRss>http://www.heavyworks.net/blog/posts/dont-be-ruthless-to-your-processes/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Solving iPhone speed issues with dynamic paging</title><link>http://www.heavyworks.net/blog/posts/solving-iphone-speed-issues-with-dynamic-paging</link> <comments>http://www.heavyworks.net/blog/posts/solving-iphone-speed-issues-with-dynamic-paging#comments</comments> <pubDate>Tue, 27 Apr 2010 01:38:21 +0000</pubDate> <dc:creator>Jan Seidl</dc:creator> <category><![CDATA[Mobile]]></category> <category><![CDATA[cydia]]></category> <category><![CDATA[iphone]]></category> <category><![CDATA[jailbreak]]></category> <category><![CDATA[page file]]></category> <category><![CDATA[performance]]></category> <category><![CDATA[swap memory]]></category> <category><![CDATA[swapfile]]></category> <category><![CDATA[top]]></category> <category><![CDATA[virtual memory]]></category> <guid
isPermaLink="false">http://www.heavyworks.net/?p=509</guid> <description><![CDATA[NOTE: This article does not teaches how to Jailbreak your iPhone nor how to install Cydia an its apps. There are plenty of info on that out there. Please do not insist. NOTE: As pointed by Robert, the amount of I/O generated by the swapfile may greatly decrease the iPhone&#8217;s SSD lifetime since is designed [...]
No related posts.]]></description> <content:encoded><![CDATA[<p><em>NOTE: This article does not teaches how to Jailbreak your iPhone nor how to install Cydia an its apps. There are plenty of info on that out there. Please do not insist.</em></p><p><em><strong>NOTE: As pointed by Robert, the amount of I/O generated by the swapfile may greatly decrease the iPhone&#8217;s SSD lifetime since is designed to be more at rest.</strong></em></p><p>After buying an iPhone 2G from a friend I just couldn&#8217;t resists and started hacking all that I could. Put on the latest firmware by the time (3.1.3) and Jailbroke it, put on <a
href="http://www.saurik.com/">Saurik</a>&#8216;s <a
href="http://cydia.saurik.com/info/cycorder/">Cycorder</a> via <a
href="http://cydia.saurik.com/">Cydia</a> (apt<a
title="apt @ Wikipedia" href="http://en.wikipedia.org/wiki/Apt" class="wikipedia" rel="external wikipedia"><sup>w</sup></a> repository) (also from Saurik) in order to gain movie recording ability but didn&#8217;t went any further than that.</p><p>Then, as I don&#8217;t have a 3G/EDGE plan on my carrier, I decided only to access internet over WiFI but even scrambling APN credentials my little buddy kept connecting to my carrier EDGE network (and thus spending my money on high taxes).</p><p>After reading a while I discovered that SBSSettings would give me the option to control EDGE status (enabled/disabled) instead of just jamming credentials (that were being ignored by the carrier anyway). Installed and it just worked like a charm&#8230;. BUT&#8230; I&#8217;ve noticed that my Spingboard page transitions became a little hangy and apps opening and closing started to take much longer than it usual. From SBSSettings pane, I constantly see my memory running out due to iPhone&#8217;s lack of memory and lots of apps in background struggling for resources.</p><p><img
src="http://www.heavyworks.net/wordpress/wp-content/uploads/slow-iphone.jpg" alt="iPhone speed issues cartoon" title="iPhone speed issues" width="608" height="300" class="aligncenter size-full wp-image-511" /></p><p><span
id="more-509"></span></p><p>Some apps are constantly running on background since boot: the Phone app (obviously) and the Mail app. I had to go often to the SBSSettings&#8217; process manager and shut down Safari or iPod app when they insisted in being kept alive even after being closed thus still consuming my precious resources. The &#8220;Free Memory&#8221; tool from SBSSettings also helped a (tiny [micro]) little bit.</p><h2>SBSSettings is your nerdy fat friend</h2><p>After some researching on iPhone speed issues I&#8217;ve <a
href="http://www.theneocell.com/sbsettings-was-slowin-system-down.htm" title="SBSSettings was slowin system down @ NeoCell">found</a> that SBSSettings, just eats tons of memory from the device. This got some discussion because someone on behalf of BigBoss commented on a post on the same blog saying that SBSSettings did not ran in background, instead it would use some Springboard hooks that would activate the app when triggered and then destroyed the app instance when closed.</p><blockquote><p>Actually SBSettings does not run in the background (which I believe is the whole premise of this article). Instead, it hooks springboard functions. When certain events inside springboard occur, springboard (which is a single process already running without sbsettings installed) causes the sbsettings window to open. When you close the window, it goes back to being idle again. It uses about 1mb of memory to exist but does not run in the background, does not slow the device down, and does not cause performance issues. It would be very nice if some research could be done before posting these sorts of articles :(</p></blockquote><p><em>some commenter entitled on behalf of BigBoss</em></p><p>Well, I decided that I didn&#8217;t want to write (or think) on things based on assumptions so I decided to take a look further into my device system, logged on by <acronym
title="Secure Shell">SSH</acronym> and ran a <code>top</code> command (had to install the &#8220;Top&#8221; app from Cydia) and there he was:</p><p><img
src="http://www.heavyworks.net/wordpress/wp-content/uploads/iphone-top.jpg" alt="" title="iPhone's top output" class="aligncenter size-full wp-image-513" /></p><p>So it is, <em>in some kind of way</em>, running on background on my iPhone since the SBSSettings tab wasn&#8217;t open.</p><h2>Proposed workaround</h2><p>The proposed workaround is to <a
href="http://www.theneocell.com/say-yes-to-bossprefs-no-to-sbsettings.htm">install BossPrefs</a> (even not supporting WIFI toggling by its interface on the 3.0 firmware) that is SBSSettings &#8220;father&#8221; (where it derived from it) and is quite being discontinued by BigBoss. I haven&#8217;t tried that yet because I&#8217;m still tied emotionally with SBSSettings even with the speed issue.</p><h2>Even more heavy <strike>crap</strike> stuff</h2><p>As if I hadn&#8217;t enough problems, I also have installed Veency (for VNC<a
title="VNC @ Wikipedia" href="http://en.wikipedia.org/wiki/Vnc" class="wikipedia" rel="external wikipedia"><sup>w</sup></a> support) and OpenSSH (for <acronym
title="Secure Shell">SSH</acronym> support! RAH) and they just goes background and eat memory (and battery) as well.</p><p>Well, I benefit from <acronym
title="Secure Shell">SSH</acronym> and Veency. From <acronym
title="Secure Shell">SSH</acronym> because I&#8217;m an unix freak and like the lovely smell of an embedded shell under a *nix kernel. Besides syncing my iPhone wirelessly is convenient too. Veency is nice to read SMS messages, view notes or monitor any app from distance, for example: Working on your desktop/laptop computer and having the cellphone on your pocket or far from the table (I&#8217;m not lazy I just like connecting remotely to stuff!). They didn&#8217;t quite handle much trouble to memory because SBSSettings toggle buttons permit me to shut&#8217;em down and up whenever needed. It also keep my battery from draining unnecessarily.</p><h3>Now THAT&#8217;s heavy, baby!</h3><p>Going further down I managed to install Winterboard (also via Cydia) since I like custom themed things &#8211; just like Hell Angel&#8217;s likes custom bikes &#8211; that also runs backgrounded and thus handling the same side effects. That really lagged stuff out too.</p><p>Then I noticed things started to get very laggy, but the hell, I NEED (ok, maybe I don&#8217;t) those awesomeness! SBSSettings just give me fine control over my device. But I had to choose: look&#8217;n'feel + control or performance.</p><p>I really love all that Cydia awesomeness and when I was almost removing Winterboard, SBSSettings and such, I remembered that I&#8217;ve heard in some article that Apple didn&#8217;t allowed 3rd-party apps to be put in background because &#8220;it would drain the battery and the short iPhone memory (128M)&#8221; that struggles to support the Phone, and iPod app that are natively always running on background. So if I won&#8217;t reduce the number of backgrounded apps, the only thing left is to get more memory but, how?</p><p>I can&#8217;t solder more RAM, that would be too way extreme. Then it snapped the sysamin insde me and though that the memory issue could be aided with a swap/page file (virtual memory) but it wasn&#8217;t implemented natively on device (I believe in behalf of the type of Flash Memory on the device that lacks on read/write speed). But what the hell, why not?</p><h2>Dynamic paging</h2><p>Searching the internet I&#8217;ve found <a
href="http://modmyi.com/forums/general-iphone-chat/681840-iphone-swap-space.html">this forum topic on modmyi.com</a> that discussed the implementation of swap file (dynamic paging) on the device and, guess what, <strong>they did it</strong>. It&#8217;s a single <strong>plist</strong> file and we get a sensible less lagging and gagging.</p><p>I just moved the <code>plist</code> file on the device over ssh and rebooted. It&#8217;s working quite better than before, so I don&#8217;t need to thrash my goods so soon.</p><p><img
src="http://www.heavyworks.net/wordpress/wp-content/uploads/swap-iphone.jpg" alt="" title="iPhone using swap memory" class="aligncenter size-full wp-image-514" /></p><p>I forgot to measure my iPhone load values before enabling dynamic paging (shame on me) to compare the gains so if anyone has some, please share on the comments! Hope this works for you as well as it worked for me! Do you have any other performance tips?</p><p>No related posts.</p>]]></content:encoded> <wfw:commentRss>http://www.heavyworks.net/blog/posts/solving-iphone-speed-issues-with-dynamic-paging/feed</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>Automating human intervention tasks with Expect</title><link>http://www.heavyworks.net/blog/posts/automating-human-intervention-tasks-with-expect</link> <comments>http://www.heavyworks.net/blog/posts/automating-human-intervention-tasks-with-expect#comments</comments> <pubDate>Thu, 22 Apr 2010 17:23:20 +0000</pubDate> <dc:creator>Jan Seidl</dc:creator> <category><![CDATA[System Administration]]></category> <category><![CDATA[automation]]></category> <category><![CDATA[expect]]></category> <category><![CDATA[tcl]]></category> <category><![CDATA[tk]]></category> <guid
isPermaLink="false">http://www.heavyworks.net/?p=495</guid> <description><![CDATA[I administrate several servers and SSH password management were a big issue until I changed all my servers logins to use private keys. Things got really nicer when I discovered SSH aliases. Some of my clients are hosted on shared hostings and some of them doesn&#8217;t allow password-less authentication &#8220;in behalf of my security&#8221;. Well, [...]
No related posts.]]></description> <content:encoded><![CDATA[<p>I administrate several servers and <acronym
title="Secure Shell">SSH</acronym> password management were a big issue until I changed all my servers logins to use private keys. Things got really nicer when I discovered <a
href="http://www.heavyworks.net/blog/posts/typing-less-with-ssh" title="Typing less with SSH @ Heavyworks"><acronym
title="Secure Shell">SSH</acronym> aliases</a>.</p><p>Some of my clients are hosted on shared hostings and some of them doesn&#8217;t allow password-less authentication &#8220;in behalf of my security&#8221;. Well, I can&#8217;t really afford opening my password manager, locating it and then copying and pasting back to my terminal. Too much time spent.</p><p>I have heard about expect long ago but never quite stopped to look at it since I never really had that need but in this case it came quite handy. Hop in aboard the new less typing world!<br
/> <span
id="more-495"></span></p><blockquote><p>Expect is a Unix automation and testing tool, written by Don Libes [from <a
href="http://www.nist.gov">NIST</a>] as an extension to the Tcl scripting language, for interactive applications such as telnet, ftp, passwd, fsck, rlogin, tip, ssh, and others. It uses Unix pseudo terminals to wrap up subprocesses transparently, allowing the automation of arbitrary applications that are accessed over a terminal. With Tk, interactive applications can be wrapped in X11 GUIs.</p></blockquote><p><em>Source: <a
href="http://en.wikipedia.org/wiki/Expect">Wikipedia</a></em></p><h2>Expect Overview</h2><p>Expect runs a very simple kind of script file in its own language. This script contains the logic to perform the automation and it&#8217;s called as first argument to the <code>expect</code> command. For a argument-less script named <code>fake_ssh_host-x.exp</code> the call would be.</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">expect fake_ssh_host-x.exp</pre></div></div><p>If it took any argument it would just be appended to the call:</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">expect fake_ssh_host-x.exp somefile.txt</pre></div></div><h2>Quick Expect anatomy</h2><p>Expect directives are line-separated and not terminated. Expect even has some object-notation for grouping <code>expect</code> events.</p><h3>Variables</h3><p>Variables are assigned in expect with the <code>set</code> directive.</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">set</span> pass <span style="color: #ff0000;">&quot;mypass&quot;</span></pre></div></div><p>Variables are further referenced prefixed with a dollar-sign <code>$</code>.</p><h3>Command-line arguments</h3><p>Command-line arguments are get through the <code>$argv</code> variable and the <code>lindex</code> call. Now that we have learned how to assign variables, let&#8217;s assign one with a command-line argument.</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">set</span> filename <span style="color: #7a0874; font-weight: bold;">&#91;</span>lindex <span style="color: #007800;">$argv</span> <span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#93;</span></pre></div></div><p>Note that indexes start at <code>0</code>, as the standard.<br
/> You can have multiple command-line arguments:</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">set</span> filename <span style="color: #7a0874; font-weight: bold;">&#91;</span>lindex <span style="color: #007800;">$argv</span> <span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">set</span> user <span style="color: #7a0874; font-weight: bold;">&#91;</span>lindex <span style="color: #007800;">$argv</span> <span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">set</span> host <span style="color: #7a0874; font-weight: bold;">&#91;</span>lindex <span style="color: #007800;">$argv</span> <span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#93;</span></pre></div></div><h3>Spawning the tampered process</h3><p>We use Expect in order to tamper output from a process and thus automate the inputs. We need to tell our Expect script which process it must spawn. This is done though the <code>spawn</code> directive that prefixes a normal command-line statement for that call.</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">spawn <span style="color: #c20cb9; font-weight: bold;">ssh</span> user<span style="color: #000000; font-weight: bold;">@</span>host</pre></div></div><h3>Timeout</h3><p>Timeout determines the number of seconds that the process has to respond before being considered jammed (or b0rked) and is set through the <code>timeout</code> directive, much like as a variable is.</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># one minute timeout</span>
<span style="color: #000000; font-weight: bold;">set</span> timeout <span style="color: #000000;">60</span></pre></div></div><p><em><code>timeout</code> is disabled if set to <code>-1</code></em></p><h3>Observing data</h3><p>The <code>expect</code> directive tells the script which text to expect from standard output.</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">expect <span style="color: #ff0000;">&quot;String&quot;</span></pre></div></div><h3>Posting data</h3><p>Posting data to standard input is done through the <code>send</code> directive. This statement when precede by an <code>expect</code> statement will execute only when given string matched.</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">send <span style="color: #007800;">$pass</span></pre></div></div><h3>Grouping expectations and posts</h3><p>This kinda object-notation is used to couple <code>expect</code>/<code>send</code> statements.</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">expect <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #ff0000;">&quot;password:&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
		send <span style="color: #ff0000;">&quot;<span style="color: #007800;">$pass</span><span style="color: #000099; font-weight: bold;">\r</span>&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #666666; font-style: italic;"># or shortened</span>
expect <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #ff0000;">&quot;password:&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span> send <span style="color: #ff0000;">&quot;<span style="color: #007800;">$pass</span><span style="color: #000099; font-weight: bold;">\r</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div><p>If you need to append more commands on an <code>expect</code> block just append the line within the expected element closure (in expanded form) or append to the line in a semi-colon delimited form.</p><div
class="wp_syntax"><div
class="code"><pre class="bash" styl
