<?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: Coprocess exit code reading in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/coprocess-exit-code-reading/m-p/3445140#M707822</link>
    <description>I'm finding other things not supported in HP KSH... for instance I can't read from /dev/tcp like on other systems...  Thanks for you help though!  I'll just trap my exit in the child process and send a message on how it will terminate to stdout.</description>
    <pubDate>Mon, 20 Dec 2004 10:06:41 GMT</pubDate>
    <dc:creator>Jeff Carlin</dc:creator>
    <dc:date>2004-12-20T10:06:41Z</dc:date>
    <item>
      <title>Coprocess exit code reading</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/coprocess-exit-code-reading/m-p/3445134#M707816</link>
      <description>Does anyone know how I can read the exit code from one of my coprocess' in a ksh script?  I need to know if the coprocess exited with a 0, 1 or 2. I could write into the coprocess to print out how it was going to exit and have the master script read that from the pipe, but I think reading the exit code would be cleaner and safer.  Any tips?</description>
      <pubDate>Thu, 16 Dec 2004 11:21:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/coprocess-exit-code-reading/m-p/3445134#M707816</guid>
      <dc:creator>Jeff Carlin</dc:creator>
      <dc:date>2004-12-16T11:21:46Z</dc:date>
    </item>
    <item>
      <title>Re: Coprocess exit code reading</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/coprocess-exit-code-reading/m-p/3445135#M707817</link>
      <description>&lt;BR /&gt;define a repear trap at the begninning:&lt;BR /&gt;&lt;BR /&gt;export COPID COPIDERR&lt;BR /&gt;trap 'wait $COPID; COPIDERR=$?' CHLD&lt;BR /&gt;&lt;BR /&gt;immediately after spawning the coproc, capture its PID:&lt;BR /&gt;&lt;BR /&gt;coproc |&amp;amp;&lt;BR /&gt;COPID=$!&lt;BR /&gt;&lt;BR /&gt;when the coprocess terminates, COPIDERR will be set to its exit status, so you can look at it whenever you want.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 16 Dec 2004 17:11:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/coprocess-exit-code-reading/m-p/3445135#M707817</guid>
      <dc:creator>Jordan Bean</dc:creator>
      <dc:date>2004-12-16T17:11:25Z</dc:date>
    </item>
    <item>
      <title>Re: Coprocess exit code reading</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/coprocess-exit-code-reading/m-p/3445136#M707818</link>
      <description>It didn't work, but your suggestion sent me back to the "books".  I found this tidbit:&lt;BR /&gt;&lt;BR /&gt;"Traps are not processed while a job is waiting for a foreground process. Thus, a  trap on CHLD won't be executed until the foreground job terminates."&lt;BR /&gt;&lt;BR /&gt;What does this mean?&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 17 Dec 2004 10:10:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/coprocess-exit-code-reading/m-p/3445136#M707818</guid>
      <dc:creator>Jeff Carlin</dc:creator>
      <dc:date>2004-12-17T10:10:10Z</dc:date>
    </item>
    <item>
      <title>Re: Coprocess exit code reading</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/coprocess-exit-code-reading/m-p/3445137#M707819</link>
      <description>That means if a another command is running in the foreground at the time the background child terminates, the trap will not run until the foreground command finishes. This is fine.&lt;BR /&gt;&lt;BR /&gt;Can you attach your script or show us the relevant segments?&lt;BR /&gt;&lt;BR /&gt;Make sure that you are using single quotes:&lt;BR /&gt;&lt;BR /&gt;trap 'wait $COPID; COPIDERR=$?' CHLD&lt;BR /&gt;&lt;BR /&gt;trap commands are evaluated twice: once when defined and once when taken. This means that&lt;BR /&gt;&lt;BR /&gt;trap "wait $COPID; COPIDERR=$?" CHLD&lt;BR /&gt;&lt;BR /&gt;may set the trap to 'wait; COPIDERR=' which is meaningless.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 17 Dec 2004 12:54:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/coprocess-exit-code-reading/m-p/3445137#M707819</guid>
      <dc:creator>Jordan Bean</dc:creator>
      <dc:date>2004-12-17T12:54:16Z</dc:date>
    </item>
    <item>
      <title>Re: Coprocess exit code reading</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/coprocess-exit-code-reading/m-p/3445138#M707820</link>
      <description>Sure, here are my test scripts...</description>
      <pubDate>Fri, 17 Dec 2004 13:38:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/coprocess-exit-code-reading/m-p/3445138#M707820</guid>
      <dc:creator>Jeff Carlin</dc:creator>
      <dc:date>2004-12-17T13:38:02Z</dc:date>
    </item>
    <item>
      <title>Re: Coprocess exit code reading</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/coprocess-exit-code-reading/m-p/3445139#M707821</link>
      <description>Uh oh. I wrote my own test script and learned that the CHLD signal doesn't appear to be handled by either korn or posix, at least not in HP-UX. The open source Korn shell from AT&amp;amp;T handles it immediately. You will need to reap it at some point late in the script when you know the coprocess has finished.</description>
      <pubDate>Fri, 17 Dec 2004 19:19:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/coprocess-exit-code-reading/m-p/3445139#M707821</guid>
      <dc:creator>Jordan Bean</dc:creator>
      <dc:date>2004-12-17T19:19:56Z</dc:date>
    </item>
    <item>
      <title>Re: Coprocess exit code reading</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/coprocess-exit-code-reading/m-p/3445140#M707822</link>
      <description>I'm finding other things not supported in HP KSH... for instance I can't read from /dev/tcp like on other systems...  Thanks for you help though!  I'll just trap my exit in the child process and send a message on how it will terminate to stdout.</description>
      <pubDate>Mon, 20 Dec 2004 10:06:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/coprocess-exit-code-reading/m-p/3445140#M707822</guid>
      <dc:creator>Jeff Carlin</dc:creator>
      <dc:date>2004-12-20T10:06:41Z</dc:date>
    </item>
  </channel>
</rss>

