<?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: Trap in Korn shell scripts in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/trap-in-korn-shell-scripts/m-p/3533959#M701552</link>
    <description>You can also replace all your subshell commands as follows.&lt;BR /&gt;&lt;BR /&gt;sh -c ""trap 'echo "Dont kill me"' USR1";sub_shell_command1;sub_shell_command2"&lt;BR /&gt;&lt;BR /&gt;Anil</description>
    <pubDate>Thu, 28 Apr 2005 07:55:29 GMT</pubDate>
    <dc:creator>RAC_1</dc:creator>
    <dc:date>2005-04-28T07:55:29Z</dc:date>
    <item>
      <title>Trap in Korn shell scripts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/trap-in-korn-shell-scripts/m-p/3533955#M701548</link>
      <description>Folks,&lt;BR /&gt;&lt;BR /&gt;I have a scheduled job which will run as follows,&lt;BR /&gt;&lt;BR /&gt;script1 calles script2,script2 calls script3 and ends.&lt;BR /&gt;&lt;BR /&gt;I opened an earlier thread where I mentioned someone (may be the OS or scheduler) is sending USR1 signals to some of the shell scripts. &lt;BR /&gt;&lt;BR /&gt;So I placed a trap for script1 as ,&lt;BR /&gt;&lt;BR /&gt;trap 'echo "Dont kill me"' USR1&lt;BR /&gt;&lt;BR /&gt;This worked. But the subshells are still getting killed by the USR1's . Is there a away I can set a trap in a script which will be applicable for all the scripts that are triggered by that script?.&lt;BR /&gt;&lt;BR /&gt;Regds,&lt;BR /&gt;&lt;BR /&gt;Kaps</description>
      <pubDate>Thu, 28 Apr 2005 07:31:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/trap-in-korn-shell-scripts/m-p/3533955#M701548</guid>
      <dc:creator>KapilRaj</dc:creator>
      <dc:date>2005-04-28T07:31:31Z</dc:date>
    </item>
    <item>
      <title>Re: Trap in Korn shell scripts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/trap-in-korn-shell-scripts/m-p/3533956#M701549</link>
      <description>The trap command is unique to each script (and function), so you'll need to include the trap in each script. See the comments about traps in the ksh man page.</description>
      <pubDate>Thu, 28 Apr 2005 07:45:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/trap-in-korn-shell-scripts/m-p/3533956#M701549</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2005-04-28T07:45:08Z</dc:date>
    </item>
    <item>
      <title>Re: Trap in Korn shell scripts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/trap-in-korn-shell-scripts/m-p/3533957#M701550</link>
      <description>Why spawn sub-shells?? Can you do as follows.&lt;BR /&gt;{ cm1 ; cm2; } --&amp;gt; subshells commands.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 28 Apr 2005 07:53:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/trap-in-korn-shell-scripts/m-p/3533957#M701550</guid>
      <dc:creator>RAC_1</dc:creator>
      <dc:date>2005-04-28T07:53:06Z</dc:date>
    </item>
    <item>
      <title>Re: Trap in Korn shell scripts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/trap-in-korn-shell-scripts/m-p/3533958#M701551</link>
      <description>Thank you... But don't you think it is much of a pain ? , I have some shell scripts in which, I dynamically create some shell scripts, execute them and then delete them. I need a way to trap the whole chain .. Help me guys ..&lt;BR /&gt;&lt;BR /&gt;Do you know why USR1's default action is terminate for a korn shell ? .&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Regds,&lt;BR /&gt;&lt;BR /&gt;Kaps</description>
      <pubDate>Thu, 28 Apr 2005 07:53:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/trap-in-korn-shell-scripts/m-p/3533958#M701551</guid>
      <dc:creator>KapilRaj</dc:creator>
      <dc:date>2005-04-28T07:53:35Z</dc:date>
    </item>
    <item>
      <title>Re: Trap in Korn shell scripts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/trap-in-korn-shell-scripts/m-p/3533959#M701552</link>
      <description>You can also replace all your subshell commands as follows.&lt;BR /&gt;&lt;BR /&gt;sh -c ""trap 'echo "Dont kill me"' USR1";sub_shell_command1;sub_shell_command2"&lt;BR /&gt;&lt;BR /&gt;Anil</description>
      <pubDate>Thu, 28 Apr 2005 07:55:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/trap-in-korn-shell-scripts/m-p/3533959#M701552</guid>
      <dc:creator>RAC_1</dc:creator>
      <dc:date>2005-04-28T07:55:29Z</dc:date>
    </item>
    <item>
      <title>Re: Trap in Korn shell scripts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/trap-in-korn-shell-scripts/m-p/3533960#M701553</link>
      <description>Try this.&lt;BR /&gt;sh -c ""trap 'echo "Dont kill me"' USR1";sub_shell_comman1"&lt;BR /&gt;&lt;BR /&gt;Anil</description>
      <pubDate>Thu, 28 Apr 2005 08:25:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/trap-in-korn-shell-scripts/m-p/3533960#M701553</guid>
      <dc:creator>RAC_1</dc:creator>
      <dc:date>2005-04-28T08:25:23Z</dc:date>
    </item>
    <item>
      <title>Re: Trap in Korn shell scripts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/trap-in-korn-shell-scripts/m-p/3533961#M701554</link>
      <description>&amp;gt; Thank you... But don't you think it is much of a pain ? , I have some shell scripts in which, I dynamically create some shell scripts, execute them and then delete them. I need a way to trap the whole chain .. Help me guys ..&lt;BR /&gt;&lt;BR /&gt;You need to find the source of the kill -SIGUSR1 commands. The operating system never does this automatically. Check all your cron jobs to find the culprit. There is nothing normal about kill -16 being sent to selected processes. NOTE: if kill -16 was sent to every process, your system would immediately crash or hang, so there is something selective about the kill signals. I would look for scripts that have kill commands, and rewrite any that use ps piped to grep. It is not very common to use SIGUSR1 (or SIGUSR2) so I suspect some local script writing is the problem.&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Do you know why USR1's default action is terminate for a korn shell ? .&lt;BR /&gt;&lt;BR /&gt;Standard Unix behavior. See the man page for kill(1) &lt;BR /&gt;</description>
      <pubDate>Thu, 28 Apr 2005 08:32:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/trap-in-korn-shell-scripts/m-p/3533961#M701554</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2005-04-28T08:32:05Z</dc:date>
    </item>
    <item>
      <title>Re: Trap in Korn shell scripts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/trap-in-korn-shell-scripts/m-p/3533962#M701555</link>
      <description>Kaps Wrote:&lt;BR /&gt;&amp;gt; Do you know why USR1's default action is &lt;BR /&gt;&amp;gt; terminate for a korn shell ? .&lt;BR /&gt;&lt;BR /&gt;Because SIGUSR1 (and SIGUSR2) are meant to be &lt;BR /&gt;user defined signals. System never sends those &lt;BR /&gt;signals. The intention is, if you are developing a &lt;BR /&gt;software that creates multiple processes and you &lt;BR /&gt;need to have a machanism for them to &lt;BR /&gt;communicate, you could use SIGUSR1 and &lt;BR /&gt;SIGUSR2. Typically, one of your process should &lt;BR /&gt;send the signal and the recipient should write a &lt;BR /&gt;handler that handles it. If you don't have a signal &lt;BR /&gt;handler but still receive those signals, the system &lt;BR /&gt;has no idea what to do. So killing the process is an &lt;BR /&gt;obvious choice for default action.&lt;BR /&gt;&lt;BR /&gt;As others have already suggested, you need to &lt;BR /&gt;figureout who is sending you the SIGUSR1 and &lt;BR /&gt;why?&lt;BR /&gt;&lt;BR /&gt;- Biswajit&lt;BR /&gt;</description>
      <pubDate>Thu, 28 Apr 2005 13:07:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/trap-in-korn-shell-scripts/m-p/3533962#M701555</guid>
      <dc:creator>Biswajit Tripathy</dc:creator>
      <dc:date>2005-04-28T13:07:23Z</dc:date>
    </item>
    <item>
      <title>Re: Trap in Korn shell scripts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/trap-in-korn-shell-scripts/m-p/3533963#M701556</link>
      <description>if you replace your trap "command" SIGUSR1 by a&lt;BR /&gt;trap "" SIGUSR1&lt;BR /&gt;then the signal will be sigignored, and the sigignore is inherited form parent to child&lt;BR /&gt;process.&lt;BR /&gt;</description>
      <pubDate>Fri, 29 Apr 2005 06:46:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/trap-in-korn-shell-scripts/m-p/3533963#M701556</guid>
      <dc:creator>Laurent Menase</dc:creator>
      <dc:date>2005-04-29T06:46:47Z</dc:date>
    </item>
  </channel>
</rss>

