<?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>tail -f /dev/null &#187; if</title>
	<atom:link href="http://tfdn.radiofreeomaha.net/tag/if/feed/" rel="self" type="application/rss+xml" />
	<link>http://tfdn.radiofreeomaha.net</link>
	<description>Tips, notes, HOWTOs</description>
	<lastBuildDate>Fri, 20 Aug 2010 04:13:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Spawning Sub-Shells</title>
		<link>http://tfdn.radiofreeomaha.net/2008/12/spawning-sub-shells/</link>
		<comments>http://tfdn.radiofreeomaha.net/2008/12/spawning-sub-shells/#comments</comments>
		<pubDate>Thu, 18 Dec 2008 21:59:56 +0000</pubDate>
		<dc:creator>Uncle Jubba</dc:creator>
				<category><![CDATA[CLI]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[else]]></category>
		<category><![CDATA[if]]></category>
		<category><![CDATA[subshell]]></category>
		<category><![CDATA[while]]></category>

		<guid isPermaLink="false">http://tfdn.radiofreeomaha.net/?p=48</guid>
		<description><![CDATA[Creating sub-shells in bash is simple: just put the commands to be run in the sub-shell inside parentheses. This causes bash to start the commands as a separate process. This group of commands essentially acts like a separate script file, their input/output can be collectively redirected and/or they can be executed in the background by [...]
No related posts.]]></description>
			<content:encoded><![CDATA[<blockquote><p>Creating sub-shells in bash is simple: just put the commands to be run in the sub-shell inside parentheses. This causes bash to start the commands as a separate process. This group of commands essentially acts like a separate script file, their input/output can be collectively redirected and/or they can be executed in the background by following the closing parenthesis with an ampersand.</p></blockquote>
<pre>
<pre class="brush: bash">#!/bin/bash

server_cmd=server
pid_file=$(basename $server_cmd .sh).pid
log_file=$(basename $server_cmd .sh).log

(
    echo &quot;Starting server&quot;
    echo &quot;Doing some init work&quot;
    $server_cmd   # server becomes a daemon

    while true
    do
        if [[ -f $pid_file ]]; then
            sleep 15
        else
            break
        fi
    done
    mail -s &quot;Server exitted&quot; joe@example.com &lt;&lt;&lt;CRAP

) 2&gt;&amp;1 &gt;&gt; $log_file &amp;

echo &quot;Server started&quot;</pre>
<p>quote and example via <a href="http://www.linuxjournal.com/content/bash-sub-shells" target="_blank">LinuxJournal</a></p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://tfdn.radiofreeomaha.net/2008/12/spawning-sub-shells/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

