<?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: function used to create background task hangs on exit when |tee present in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/function-used-to-create-background-task-hangs-on-exit-when-tee/m-p/2760228#M72202</link>
    <description>Hi Randy,&lt;BR /&gt;&lt;BR /&gt;if your function dwit is the last command line in your script then try to call it like this:&lt;BR /&gt;&lt;BR /&gt;script_name | tee log 2&amp;gt;&amp;amp;1&lt;BR /&gt;&lt;BR /&gt;this should do it for you.&lt;BR /&gt;&lt;BR /&gt;Allways stay on the bright side of life!&lt;BR /&gt;&lt;BR /&gt;Peter</description>
    <pubDate>Wed, 10 Jul 2002 05:49:08 GMT</pubDate>
    <dc:creator>Peter Kloetgen</dc:creator>
    <dc:date>2002-07-10T05:49:08Z</dc:date>
    <item>
      <title>function used to create background task hangs on exit when |tee present</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/function-used-to-create-background-task-hangs-on-exit-when-tee/m-p/2760226#M72200</link>
      <description>I created a ksh script "x" which calls a function "dwit". dwit creates several background tasks using:&lt;BR /&gt;nohup /cpf/bin/fms &amp;amp;&lt;BR /&gt;&lt;BR /&gt;When I execute dwit in the following formats it works:&lt;BR /&gt;dwit&lt;BR /&gt;dwit &amp;gt; log&lt;BR /&gt;dwit &amp;gt;log 2&amp;gt;&amp;amp;1&lt;BR /&gt;&lt;BR /&gt;When I use the |tee command:&lt;BR /&gt;dwit |tee log&lt;BR /&gt;dwit 2&amp;gt;&amp;amp;1 |tee log&lt;BR /&gt;dwit |tee log 2&amp;gt;&amp;amp;1&lt;BR /&gt;the dwit command hangs after executing the last command which is "exit".&lt;BR /&gt;&lt;BR /&gt;I have to stop the "x" script with a ctrl-c.&lt;BR /&gt;&lt;BR /&gt;I have removed the background creation from dwit and the process works fine, so the problem is related to background and |tee. &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 09 Jul 2002 14:34:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/function-used-to-create-background-task-hangs-on-exit-when-tee/m-p/2760226#M72200</guid>
      <dc:creator>Randy Goss</dc:creator>
      <dc:date>2002-07-09T14:34:57Z</dc:date>
    </item>
    <item>
      <title>Re: function used to create background task hangs on exit when |tee present</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/function-used-to-create-background-task-hangs-on-exit-when-tee/m-p/2760227#M72201</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;If tee hangs try script&lt;BR /&gt;&lt;BR /&gt;script file&lt;BR /&gt;dwit&lt;BR /&gt;exit&lt;BR /&gt;&lt;BR /&gt;Everything that happens goes to the file in copy.&lt;BR /&gt;&lt;BR /&gt;The tee hang is probably caused by this.&lt;BR /&gt;&lt;BR /&gt;Any process's children inherit the parent's open file descriptors. If the child does not close any them they stay open until the process exits and  will be passed to&lt;BR /&gt;their children in a similar mannor.&lt;BR /&gt;&lt;BR /&gt;A pipe, does not deliver an end-of-file indicator to its reading end until all processes that have  opened it for writing have closed their file descriptors.&lt;BR /&gt;&lt;BR /&gt;Thus tee, or any other command using the pipe in a comparable way,&lt;BR /&gt;will not terminate until all  descendents of the  process that inherited the pipe as the standard output have closed it or terminated.&lt;BR /&gt;&lt;BR /&gt;During a hang, the program lsof may be used to&lt;BR /&gt;determine which processes have the pipe open for reading or writing. &lt;BR /&gt;Also checking the output from a ps command will show processes that are running.&lt;BR /&gt;&lt;BR /&gt;             Steve Steel&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 10 Jul 2002 05:34:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/function-used-to-create-background-task-hangs-on-exit-when-tee/m-p/2760227#M72201</guid>
      <dc:creator>Steve Steel</dc:creator>
      <dc:date>2002-07-10T05:34:07Z</dc:date>
    </item>
    <item>
      <title>Re: function used to create background task hangs on exit when |tee present</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/function-used-to-create-background-task-hangs-on-exit-when-tee/m-p/2760228#M72202</link>
      <description>Hi Randy,&lt;BR /&gt;&lt;BR /&gt;if your function dwit is the last command line in your script then try to call it like this:&lt;BR /&gt;&lt;BR /&gt;script_name | tee log 2&amp;gt;&amp;amp;1&lt;BR /&gt;&lt;BR /&gt;this should do it for you.&lt;BR /&gt;&lt;BR /&gt;Allways stay on the bright side of life!&lt;BR /&gt;&lt;BR /&gt;Peter</description>
      <pubDate>Wed, 10 Jul 2002 05:49:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/function-used-to-create-background-task-hangs-on-exit-when-tee/m-p/2760228#M72202</guid>
      <dc:creator>Peter Kloetgen</dc:creator>
      <dc:date>2002-07-10T05:49:08Z</dc:date>
    </item>
    <item>
      <title>Re: function used to create background task hangs on exit when |tee present</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/function-used-to-create-background-task-hangs-on-exit-when-tee/m-p/2760229#M72203</link>
      <description>Steve, your clarification of my problem enabled me to fix it.&lt;BR /&gt;&lt;BR /&gt;The tasks I start from the function "dwit" run continuously until a system reboot or I kill them manually, therefore they don't close output to the pipe.&lt;BR /&gt;&lt;BR /&gt;The solution:&lt;BR /&gt;dwit now initiates the tasks as:&lt;BR /&gt;&lt;BR /&gt;nohup task &amp;gt;tasklog 2&amp;gt;&amp;amp;1 &amp;amp;&lt;BR /&gt;&lt;BR /&gt;by redirecting the child task's output to tasklog the pipe closes.&lt;BR /&gt;&lt;BR /&gt;thanks.</description>
      <pubDate>Wed, 10 Jul 2002 13:09:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/function-used-to-create-background-task-hangs-on-exit-when-tee/m-p/2760229#M72203</guid>
      <dc:creator>Randy Goss</dc:creator>
      <dc:date>2002-07-10T13:09:22Z</dc:date>
    </item>
  </channel>
</rss>

