<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Fork in shell in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/fork-in-shell/m-p/2546780#M724822</link>
    <description>Hi,&lt;BR /&gt;I think you can not use it directly.&lt;BR /&gt;Since you usally code&lt;BR /&gt;&lt;BR /&gt;fork .....;&lt;BR /&gt;if ( ...&lt;BR /&gt;  exec ...;&lt;BR /&gt;&lt;BR /&gt;in C, I guess you like to start a process.&lt;BR /&gt;&lt;BR /&gt;This can easyly done with &lt;BR /&gt;&lt;BR /&gt;commandname &amp;amp;&lt;BR /&gt;&lt;BR /&gt;Processid of this process has to be rescued from $! after the call. You can later wait for completition with wait. I use this in a delay loop for offline backups:&lt;BR /&gt;&lt;BR /&gt;shut_down_application&lt;BR /&gt;# two hours max offline !&lt;BR /&gt;sleep 7200 &amp;amp;&lt;BR /&gt;PID=$!&lt;BR /&gt;echo $PID &amp;gt; /tmp/waiter.pid&lt;BR /&gt;wait $PID&lt;BR /&gt;startup_application&lt;BR /&gt;&lt;BR /&gt;When backup is ok it kills the sleep and the application comes up again. When there is trouble with backup, the application starts at the end of my offline-time-window, regardless, what the backup job is doing.&lt;BR /&gt;&lt;BR /&gt;Volker</description>
    <pubDate>Fri, 29 Jun 2001 09:33:27 GMT</pubDate>
    <dc:creator>Volker Borowski</dc:creator>
    <dc:date>2001-06-29T09:33:27Z</dc:date>
    <item>
      <title>Fork in shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/fork-in-shell/m-p/2546779#M724821</link>
      <description>Hi&lt;BR /&gt;  Can we use fork in shell script.&lt;BR /&gt;&lt;BR /&gt;Praveen</description>
      <pubDate>Fri, 29 Jun 2001 09:12:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/fork-in-shell/m-p/2546779#M724821</guid>
      <dc:creator>Praveen Bezawada</dc:creator>
      <dc:date>2001-06-29T09:12:35Z</dc:date>
    </item>
    <item>
      <title>Re: Fork in shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/fork-in-shell/m-p/2546780#M724822</link>
      <description>Hi,&lt;BR /&gt;I think you can not use it directly.&lt;BR /&gt;Since you usally code&lt;BR /&gt;&lt;BR /&gt;fork .....;&lt;BR /&gt;if ( ...&lt;BR /&gt;  exec ...;&lt;BR /&gt;&lt;BR /&gt;in C, I guess you like to start a process.&lt;BR /&gt;&lt;BR /&gt;This can easyly done with &lt;BR /&gt;&lt;BR /&gt;commandname &amp;amp;&lt;BR /&gt;&lt;BR /&gt;Processid of this process has to be rescued from $! after the call. You can later wait for completition with wait. I use this in a delay loop for offline backups:&lt;BR /&gt;&lt;BR /&gt;shut_down_application&lt;BR /&gt;# two hours max offline !&lt;BR /&gt;sleep 7200 &amp;amp;&lt;BR /&gt;PID=$!&lt;BR /&gt;echo $PID &amp;gt; /tmp/waiter.pid&lt;BR /&gt;wait $PID&lt;BR /&gt;startup_application&lt;BR /&gt;&lt;BR /&gt;When backup is ok it kills the sleep and the application comes up again. When there is trouble with backup, the application starts at the end of my offline-time-window, regardless, what the backup job is doing.&lt;BR /&gt;&lt;BR /&gt;Volker</description>
      <pubDate>Fri, 29 Jun 2001 09:33:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/fork-in-shell/m-p/2546780#M724822</guid>
      <dc:creator>Volker Borowski</dc:creator>
      <dc:date>2001-06-29T09:33:27Z</dc:date>
    </item>
    <item>
      <title>Re: Fork in shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/fork-in-shell/m-p/2546781#M724823</link>
      <description>&lt;BR /&gt;Volker is right here..&lt;BR /&gt;&lt;BR /&gt;another thing you can from the shell is&lt;BR /&gt;&lt;BR /&gt;exec &lt;COMMAND&gt;&lt;BR /&gt;&lt;BR /&gt;this will replace your current shell with &lt;COMMAND&gt;&lt;BR /&gt;and your shell is thus killed.&lt;BR /&gt;&lt;BR /&gt;you might use this to startup some daemons for example&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/COMMAND&gt;&lt;/COMMAND&gt;</description>
      <pubDate>Fri, 29 Jun 2001 10:13:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/fork-in-shell/m-p/2546781#M724823</guid>
      <dc:creator>Rainer von Bongartz</dc:creator>
      <dc:date>2001-06-29T10:13:48Z</dc:date>
    </item>
    <item>
      <title>Re: Fork in shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/fork-in-shell/m-p/2546782#M724824</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Another option if you want something very much like C fork(),exec(),wait(), etc. is to use perl.&lt;BR /&gt;&lt;BR /&gt;It is also very easy to add a signal handler to handle timeout issues in perl.&lt;BR /&gt;&lt;BR /&gt;You should also be aware that in the shell&lt;BR /&gt;you can &lt;BR /&gt;cmd1 &amp;amp;&lt;BR /&gt;cmd2 &amp;amp;&lt;BR /&gt;cmd3 &amp;amp;&lt;BR /&gt;wait&lt;BR /&gt;&lt;BR /&gt;In this case wait without an argument will&lt;BR /&gt;block until all the background processes have finished.&lt;BR /&gt;&lt;BR /&gt;Regards, Clay</description>
      <pubDate>Fri, 29 Jun 2001 13:02:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/fork-in-shell/m-p/2546782#M724824</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2001-06-29T13:02:44Z</dc:date>
    </item>
    <item>
      <title>Re: Fork in shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/fork-in-shell/m-p/2546783#M724825</link>
      <description>Shells don't have a fork command, but all external commands are forked unless exec'd.&lt;BR /&gt;&lt;BR /&gt;If you want the parent to talk to the child, invoke the child as a co-process (|&amp;amp;) and use the -p option for read and print to talk with it. For example:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;telnet localhost smtp |&amp;amp;&lt;BR /&gt;master=$!&lt;BR /&gt;if kill -0 $master&lt;BR /&gt;then&lt;BR /&gt;  # find the first 200 response&lt;BR /&gt;  while read -p line&lt;BR /&gt;  do&lt;BR /&gt;    case $line in&lt;BR /&gt;      (2*) smtp_ready=1;;&lt;BR /&gt;    esac&lt;BR /&gt;  done&lt;BR /&gt;else&lt;BR /&gt;  echo could not contact smtp server&lt;BR /&gt;  exit 1&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;if [ $smtp_ready -eq 1 ]&lt;BR /&gt;then&lt;BR /&gt;  # SMTP dialog using read -p and print -p&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;# gracefully terminate the child...&lt;BR /&gt;if kill -0 $master&lt;BR /&gt;then&lt;BR /&gt;  print -p quit&lt;BR /&gt;  kill $master&lt;BR /&gt;  wait $master&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;I pulled this out of the air, so please excuse any syntax or logical errors.&lt;BR /&gt;</description>
      <pubDate>Sat, 30 Jun 2001 00:11:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/fork-in-shell/m-p/2546783#M724825</guid>
      <dc:creator>Jordan Bean</dc:creator>
      <dc:date>2001-06-30T00:11:41Z</dc:date>
    </item>
  </channel>
</rss>

